mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
Add child artifact digest in reference model
As we only provide the API to get artifact information via project name, repository name and digest, the digest of child artifact must be returned Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
5cf0481b51
commit
7930e4f38a
@ -467,6 +467,9 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
description: The child ID of the reference
|
description: The child ID of the reference
|
||||||
|
child_digest:
|
||||||
|
type: string
|
||||||
|
description: The digest of the child artifact
|
||||||
platform:
|
platform:
|
||||||
$ref: '#/definitions/Platform'
|
$ref: '#/definitions/Platform'
|
||||||
Platform:
|
Platform:
|
||||||
|
@ -48,6 +48,7 @@ func (a *Artifact) ToSwagger() *models.Artifact {
|
|||||||
for _, reference := range a.References {
|
for _, reference := range a.References {
|
||||||
ref := &models.Reference{
|
ref := &models.Reference{
|
||||||
ChildID: reference.ChildID,
|
ChildID: reference.ChildID,
|
||||||
|
ChildDigest: reference.ChildDigest,
|
||||||
ParentID: reference.ParentID,
|
ParentID: reference.ParentID,
|
||||||
}
|
}
|
||||||
if reference.Platform != nil {
|
if reference.Platform != nil {
|
||||||
|
@ -127,6 +127,11 @@ func (m *manager) assemble(ctx context.Context, art *dao.Artifact) (*Artifact, e
|
|||||||
for _, ref := range refs {
|
for _, ref := range refs {
|
||||||
reference := &Reference{}
|
reference := &Reference{}
|
||||||
reference.From(ref)
|
reference.From(ref)
|
||||||
|
art, err := m.dao.Get(ctx, reference.ChildID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
reference.ChildDigest = art.Digest
|
||||||
artifact.References = append(artifact.References, reference)
|
artifact.References = append(artifact.References, reference)
|
||||||
}
|
}
|
||||||
return artifact, nil
|
return artifact, nil
|
||||||
|
@ -105,6 +105,9 @@ func (m *managerTestSuite) TestAssemble() {
|
|||||||
ChildID: 3,
|
ChildID: 3,
|
||||||
},
|
},
|
||||||
}, nil)
|
}, nil)
|
||||||
|
m.dao.On("Get").Return(&dao.Artifact{
|
||||||
|
Digest: "digest",
|
||||||
|
}, nil)
|
||||||
artifact, err := m.mgr.assemble(nil, art)
|
artifact, err := m.mgr.assemble(nil, art)
|
||||||
m.Require().Nil(err)
|
m.Require().Nil(err)
|
||||||
m.dao.AssertExpectations(m.T())
|
m.dao.AssertExpectations(m.T())
|
||||||
|
@ -103,6 +103,7 @@ func (a *Artifact) To() *dao.Artifact {
|
|||||||
type Reference struct {
|
type Reference struct {
|
||||||
ParentID int64
|
ParentID int64
|
||||||
ChildID int64
|
ChildID int64
|
||||||
|
ChildDigest string // As we only provide the API based on digest rather than ID, the digest of child artifact is needed
|
||||||
Platform *v1.Platform
|
Platform *v1.Platform
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user