From 69bc15f0ccb029c849141b8d516e2b3f0144a29a Mon Sep 17 00:00:00 2001 From: Shengwen Yu Date: Fri, 25 Aug 2023 14:47:12 +0800 Subject: [PATCH] Fix: conformance test "References setup" of "Content Discovery" Signed-off-by: Shengwen Yu --- src/controller/artifact/processor/default.go | 10 ++++++++-- src/server/middleware/subject/subject.go | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/controller/artifact/processor/default.go b/src/controller/artifact/processor/default.go index e8fea66f2b5..616f3600864 100644 --- a/src/controller/artifact/processor/default.go +++ b/src/controller/artifact/processor/default.go @@ -111,8 +111,14 @@ func (d *defaultProcessor) AbstractMetadata(ctx context.Context, artifact *artif metadata := map[string]interface{}{} // Some artifact may not have empty config layer. if mani.Config.Size != 0 { - if err := json.NewDecoder(blob).Decode(&metadata); err != nil { - return err + if mani.Config.MediaType == v1.MediaTypeImageConfig || mani.Config.MediaType == schema2.MediaTypeImageConfig { + if err := json.NewDecoder(blob).Decode(&metadata); err != nil { + log.Errorf("failed to decode metadata, err=%v", err) + return err + } + } else { + log.Infof("do not decode mani.Config.Digest=[%s], because mani.Config.MediaType is not %s, or %s", + mani.Config.Digest.String(), v1.MediaTypeImageConfig, schema2.MediaTypeImageConfig) } } // Populate all metadata into the ExtraAttrs first. diff --git a/src/server/middleware/subject/subject.go b/src/server/middleware/subject/subject.go index b285891e70a..21b7ba49baf 100644 --- a/src/server/middleware/subject/subject.go +++ b/src/server/middleware/subject/subject.go @@ -146,7 +146,9 @@ func Middleware() func(http.Handler) http.Handler { return err } } - w.Header().Set("OCI-Subject", subjectArt.Digest) + // subjectArt could be nil + // w.Header().Set("OCI-Subject", subjectArt.Digest) + w.Header().Set("OCI-Subject", mf.Subject.Digest.String()) } return nil