1
0
mirror of https://github.com/openshift/image-registry.git synced 2026-02-05 09:45:55 +01:00

pkg/dockerregistry/server/manifesthandler: add manifest list handler

This commit is contained in:
Flavian Missi
2023-01-25 16:27:42 +01:00
parent 49566f6c22
commit 275c011fbd
2 changed files with 50 additions and 1 deletions

View File

@@ -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)
}

View File

@@ -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
}