diff --git a/pkg/dockerregistry/server/manifesthandler/manifesthandler.go b/pkg/dockerregistry/server/manifesthandler/manifesthandler.go index 3e433bec1..d5be2f2e5 100644 --- a/pkg/dockerregistry/server/manifesthandler/manifesthandler.go +++ b/pkg/dockerregistry/server/manifesthandler/manifesthandler.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/docker/distribution" - _ "github.com/docker/distribution/manifest/manifestlist" + "github.com/docker/distribution/manifest/manifestlist" "github.com/docker/distribution/manifest/ocischema" "github.com/docker/distribution/manifest/schema1" "github.com/docker/distribution/manifest/schema2" @@ -46,6 +46,8 @@ func NewManifestHandler(serverAddr string, blobStore distribution.BlobStore, man return &manifestSchema2Handler{blobStore: blobStore, manifest: t}, nil case *ocischema.DeserializedManifest: return &manifestOCIHandler{blobStore: blobStore, manifest: t}, nil + case *manifestlist.DeserializedManifestList: + return &manifestListHandler{manifest: t}, nil default: return nil, fmt.Errorf("unsupported manifest type %T", manifest) } diff --git a/pkg/dockerregistry/server/manifesthandler/manifestlisthandler.go b/pkg/dockerregistry/server/manifesthandler/manifestlisthandler.go new file mode 100644 index 000000000..c2566dfb7 --- /dev/null +++ b/pkg/dockerregistry/server/manifesthandler/manifestlisthandler.go @@ -0,0 +1,47 @@ +package manifesthandler + +import ( + "context" + + "github.com/docker/distribution" + "github.com/docker/distribution/manifest/manifestlist" + "github.com/opencontainers/go-digest" + imageapiv1 "github.com/openshift/api/image/v1" +) + +type manifestListHandler struct { + manifest *manifestlist.DeserializedManifestList +} + +var _ ManifestHandler = &manifestListHandler{} + +func (h *manifestListHandler) Config(ctx context.Context) ([]byte, error) { + return nil, nil +} + +func (h *manifestListHandler) Manifest() distribution.Manifest { + return h.manifest +} + +func (h *manifestListHandler) Layers(ctx context.Context) (string, []imageapiv1.ImageLayer, error) { + return "", nil, nil +} + +func (h *manifestListHandler) Digest() (digest.Digest, error) { + _, p, err := h.manifest.Payload() + if err != nil { + return "", err + } + return digest.FromBytes(p), nil +} + +func (h *manifestListHandler) Payload() (mediaType string, payload []byte, canonical []byte, err error) { + mt, p, err := h.manifest.Payload() + return mt, p, p, err +} + +func (h *manifestListHandler) Verify(ctx context.Context, skipDependencyVerification bool) error { + // we could verify that the sub-manifests exist, but that would get on the way + // of supporting sparse manifest lists in the future so we verify nothing. + return nil +}