Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conformance test -- set referrers artifactType with actual type #19260

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/controller/artifact/processor/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@
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
}

Check warning on line 118 in src/controller/artifact/processor/default.go

View check run for this annotation

Codecov / codecov/patch

src/controller/artifact/processor/default.go#L115-L118

Added lines #L115 - L118 were not covered by tests
} 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.
Expand Down
4 changes: 3 additions & 1 deletion src/server/middleware/subject/subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/server/registry/referrers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
at := req.URL.Query().Get("artifactType")
var filter string
if at != "" {
filter = "artifactType"
filter = at

Check warning on line 57 in src/server/registry/referrers.go

View check run for this annotation

Codecov / codecov/patch

src/server/registry/referrers.go#L57

Added line #L57 was not covered by tests
}

// Check if the reference is a valid digest
Expand Down Expand Up @@ -179,7 +179,7 @@

// WriteResponse to the client
func (o *listReferrersOK) WriteResponse(rw http.ResponseWriter) {
rw.Header().Set("Content-Type", "application/json; charset=utf-8")
rw.Header().Set("Content-Type", "application/vnd.oci.image.index.v1+json")

link := o.Link
if link != "" {
Expand Down
Loading