mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 16:35:44 +00:00
fix issue 19392 (#19437)
Needs to set the repo when to handle the accessory before subject manifest. Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
663d0b81a7
commit
f9ab185ed0
|
@ -156,7 +156,7 @@ func Middleware() func(http.Handler) http.Handler {
|
||||||
// In certain cases, the OCI client may push the subject artifact and accessory in either order.
|
// In certain cases, the OCI client may push the subject artifact and accessory in either order.
|
||||||
// Therefore, it is necessary to handle situations where the client pushes the accessory ahead of the subject artifact.
|
// Therefore, it is necessary to handle situations where the client pushes the accessory ahead of the subject artifact.
|
||||||
digest := digest.FromBytes(body)
|
digest := digest.FromBytes(body)
|
||||||
accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest}))
|
accs, err := accessory.Mgr.List(ctx, q.New(q.KeyWords{"SubjectArtifactDigest": digest, "SubArtifactRepo": info.Repository}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("failed to list accessory artifact: %s, error: %v", digest, err)
|
logger.Errorf("failed to list accessory artifact: %s, error: %v", digest, err)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -149,6 +149,7 @@ func (suite *MiddlewareTestSuite) addArtAcc(pid, repositoryID int64, repositoryN
|
||||||
ID: 1,
|
ID: 1,
|
||||||
ArtifactID: afid,
|
ArtifactID: afid,
|
||||||
SubArtifactDigest: dgt,
|
SubArtifactDigest: dgt,
|
||||||
|
SubArtifactRepo: repositoryName,
|
||||||
Digest: accdgt,
|
Digest: accdgt,
|
||||||
Type: accessorymodel.TypeSubject,
|
Type: accessorymodel.TypeSubject,
|
||||||
})
|
})
|
||||||
|
@ -213,6 +214,7 @@ func (suite *MiddlewareTestSuite) TestSubjectAfterAcc() {
|
||||||
accs, err := accessory.Mgr.List(suite.Context(), &q.Query{
|
accs, err := accessory.Mgr.List(suite.Context(), &q.Query{
|
||||||
Keywords: map[string]interface{}{
|
Keywords: map[string]interface{}{
|
||||||
"SubjectArtifactDigest": subArtDigest,
|
"SubjectArtifactDigest": subArtDigest,
|
||||||
|
"SubjectArtifactRepo": name,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
suite.Equal(1, len(accs))
|
suite.Equal(1, len(accs))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user