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

Bug 1622966 - Add supported media types for docker schema v1 #169

Merged
merged 1 commit into from
Aug 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions registries/adapters/apiv2_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
apiV2ManifestPath = "/v2/%v/manifests/%v"
apiV2CatalogURL = "%v/v2/_catalog"
schema1Ct = "application/vnd.docker.distribution.manifest.v1+json"
schema1CtSigned = "application/vnd.docker.distribution.manifest.v1+prettyjws"
schema2Ct = "application/vnd.docker.distribution.manifest.v2+json"
)

Expand Down Expand Up @@ -250,7 +251,7 @@ func (r APIV2Adapter) loadSpec(imageName string) (*bundle.Spec, error) {
if err != nil {
return nil, err
}
req.Header.Set("accept", fmt.Sprintf("%s,%s", schema1Ct, schema2Ct))
req.Header.Set("accept", fmt.Sprintf("%s,%s,%s", schema1Ct, schema1CtSigned, schema2Ct))

resp, err := r.client.Do(req)
if err != nil {
Expand Down Expand Up @@ -309,10 +310,13 @@ func (r APIV2Adapter) loadSpec(imageName string) (*bundle.Spec, error) {
}

func getSchemaVersion(ct string) (int, error) {
// See below links for more information on accepted media types for Docker manifests
// https://docs.docker.com/registry/spec/manifest-v2-1/
// https://docs.docker.com/registry/spec/manifest-v2-2/
switch ct {
case "":
return 0, errors.New("content-type is empty")
case schema1Ct:
case schema1Ct, schema1CtSigned:
return 1, nil
case schema2Ct:
return 2, nil
Expand Down