1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/distribution/oci.go
Sebastiaan van Stijn defb2b57a7
Update containerd client to 1.2.4
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-14 04:47:27 +01:00

29 lines
883 B
Go

package distribution
import (
"fmt"
"github.com/docker/distribution"
"github.com/docker/distribution/manifest/schema2"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
func init() {
// TODO: Remove this registration if distribution is included with OCI support
ocischemaFunc := func(b []byte) (distribution.Manifest, distribution.Descriptor, error) {
m := new(schema2.DeserializedManifest)
err := m.UnmarshalJSON(b)
if err != nil {
return nil, distribution.Descriptor{}, err
}
dgst := digest.FromBytes(b)
return m, distribution.Descriptor{Digest: dgst, Size: int64(len(b)), MediaType: ocispec.MediaTypeImageManifest}, err
}
err := distribution.RegisterManifestSchema(ocispec.MediaTypeImageManifest, ocischemaFunc)
if err != nil {
panic(fmt.Sprintf("Unable to register manifest: %s", err))
}
}