2023-03-31 10:35:30 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/distribution/distribution/v3"
|
2023-10-24 17:16:58 +00:00
|
|
|
"github.com/distribution/distribution/v3/internal/dcontext"
|
2023-03-31 10:35:30 +00:00
|
|
|
"github.com/distribution/distribution/v3/manifest/ocischema"
|
|
|
|
"github.com/opencontainers/go-digest"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ocischemaIndexHandler is a ManifestHandler that covers the OCI Image Index.
|
|
|
|
type ocischemaIndexHandler struct {
|
|
|
|
*manifestListHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ManifestHandler = &manifestListHandler{}
|
|
|
|
|
|
|
|
func (ms *ocischemaIndexHandler) Unmarshal(ctx context.Context, dgst digest.Digest, content []byte) (distribution.Manifest, error) {
|
|
|
|
dcontext.GetLogger(ms.ctx).Debug("(*ociIndexHandler).Unmarshal")
|
|
|
|
|
|
|
|
m := &ocischema.DeserializedImageIndex{}
|
|
|
|
if err := m.UnmarshalJSON(content); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return m, nil
|
|
|
|
}
|