From 7ab52528b41e57e7f1f2b3a69f599cb13d566a5e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 18 Nov 2021 00:44:55 +0100 Subject: [PATCH] [release/1.5] go.mod github.com/opencontainers/image-spec v1.0.2 - Bring mediaType out of reserved status - specs-go: adding mediaType to the index and manifest structures full diff: https://github.com/opencontainers/image-spec/compare/v1.0.1...v1.0.2 This also contains the local changes from commit fc8138468fc5d1407fec31ba362de0a7e69c2234, which fix conflicts between the types that were used locally (which added MediaType) and the re-introduced MediaType field in the image-spec. Signed-off-by: Sebastiaan van Stijn --- go.mod | 2 +- go.sum | 3 ++- images/converter/default.go | 20 +++++++++---------- integration/client/go.mod | 2 +- integration/client/go.sum | 3 ++- .../image-spec/specs-go/v1/index.go | 3 +++ .../image-spec/specs-go/v1/manifest.go | 3 +++ .../image-spec/specs-go/version.go | 2 +- vendor/modules.txt | 2 +- 9 files changed, 23 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 106cbd339408..fe517077aa1d 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/moby/sys/mountinfo v0.4.1 github.com/moby/sys/symlink v0.1.0 github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.0.1 + github.com/opencontainers/image-spec v1.0.2 github.com/opencontainers/runc v1.0.2 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 github.com/opencontainers/selinux v1.8.2 diff --git a/go.sum b/go.sum index 52b66c9b08c1..0bc0c69e2b12 100644 --- a/go.sum +++ b/go.sum @@ -348,8 +348,9 @@ github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= +github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= diff --git a/images/converter/default.go b/images/converter/default.go index 13dd513d8254..9f6d3fe082b6 100644 --- a/images/converter/default.go +++ b/images/converter/default.go @@ -112,12 +112,11 @@ func (c *defaultConverter) convertLayer(ctx context.Context, cs content.Store, d // convertManifest converts image manifests. // -// - clears `.mediaType` if the target format is OCI -// +// - converts `.mediaType` if the target format is OCI // - records diff ID changes in c.diffIDMap func (c *defaultConverter) convertManifest(ctx context.Context, cs content.Store, desc ocispec.Descriptor) (*ocispec.Descriptor, error) { var ( - manifest DualManifest + manifest ocispec.Manifest modified bool ) labels, err := readJSON(ctx, cs, &manifest, desc) @@ -128,7 +127,7 @@ func (c *defaultConverter) convertManifest(ctx context.Context, cs content.Store labels = make(map[string]string) } if images.IsDockerType(manifest.MediaType) && c.docker2oci { - manifest.MediaType = "" + manifest.MediaType = ConvertDockerMediaTypeToOCI(manifest.MediaType) modified = true } var mu sync.Mutex @@ -194,12 +193,11 @@ func (c *defaultConverter) convertManifest(ctx context.Context, cs content.Store // convertIndex converts image index. // -// - clears `.mediaType` if the target format is OCI -// +// - converts `.mediaType` if the target format is OCI // - clears manifest entries that do not match c.platformMC func (c *defaultConverter) convertIndex(ctx context.Context, cs content.Store, desc ocispec.Descriptor) (*ocispec.Descriptor, error) { var ( - index DualIndex + index ocispec.Index modified bool ) labels, err := readJSON(ctx, cs, &index, desc) @@ -210,7 +208,7 @@ func (c *defaultConverter) convertIndex(ctx context.Context, cs content.Store, d labels = make(map[string]string) } if images.IsDockerType(index.MediaType) && c.docker2oci { - index.MediaType = "" + index.MediaType = ConvertDockerMediaTypeToOCI(index.MediaType) modified = true } @@ -349,22 +347,22 @@ func clearDockerV1DummyID(cfg DualConfig) (bool, error) { } // ObjectWithMediaType represents an object with a MediaType field +// Deprecated type ObjectWithMediaType struct { // MediaType appears on Docker manifests and manifest lists. - // MediaType does not appear on OCI manifests and index MediaType string `json:"mediaType,omitempty"` } // DualManifest covers Docker manifest and OCI manifest +// Deprecated: use github.com/opencontainers/image-spec/specs-go/v1.Manifest type DualManifest struct { ocispec.Manifest - ObjectWithMediaType } // DualIndex covers Docker manifest list and OCI index +// Deprecated: use github.com/opencontainers/image-spec/specs-go/v1.Index type DualIndex struct { ocispec.Index - ObjectWithMediaType } // DualConfig covers Docker config (v1.0, v1.1, v1.2) and OCI config. diff --git a/integration/client/go.mod b/integration/client/go.mod index 47e4a4786851..66c4679b8d6a 100644 --- a/integration/client/go.mod +++ b/integration/client/go.mod @@ -13,7 +13,7 @@ require ( github.com/containerd/typeurl v1.0.2 github.com/gogo/protobuf v1.3.2 github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.0.1 + github.com/opencontainers/image-spec v1.0.2 github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 diff --git a/integration/client/go.sum b/integration/client/go.sum index c9a2245f9b16..d7a29cbb8373 100644 --- a/integration/client/go.sum +++ b/integration/client/go.sum @@ -323,8 +323,9 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= +github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go b/vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go index 4e6c4b236237..82da6c6a8989 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/v1/index.go @@ -21,6 +21,9 @@ import "github.com/opencontainers/image-spec/specs-go" type Index struct { specs.Versioned + // MediaType specificies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json` + MediaType string `json:"mediaType,omitempty"` + // Manifests references platform specific manifests. Manifests []Descriptor `json:"manifests"` diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go b/vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go index 7ff32c40ba30..d72d15ce4bb8 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/v1/manifest.go @@ -20,6 +20,9 @@ import "github.com/opencontainers/image-spec/specs-go" type Manifest struct { specs.Versioned + // MediaType specificies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json` + MediaType string `json:"mediaType,omitempty"` + // Config references a configuration object for a container, by digest. // The referenced configuration object is a JSON blob that the runtime uses to set up the container. Config Descriptor `json:"config"` diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/version.go b/vendor/github.com/opencontainers/image-spec/specs-go/version.go index 5d493df23300..0d9543f16000 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/version.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/version.go @@ -22,7 +22,7 @@ const ( // VersionMinor is for functionality in a backwards-compatible manner VersionMinor = 0 // VersionPatch is for backwards-compatible bug fixes - VersionPatch = 1 + VersionPatch = 2 // VersionDev indicates development branch. Releases will be empty string. VersionDev = "" diff --git a/vendor/modules.txt b/vendor/modules.txt index 0a8548efeeac..5bb43fc19a22 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -265,7 +265,7 @@ github.com/modern-go/reflect2 ## explicit github.com/opencontainers/go-digest github.com/opencontainers/go-digest/digestset -# github.com/opencontainers/image-spec v1.0.1 +# github.com/opencontainers/image-spec v1.0.2 ## explicit github.com/opencontainers/image-spec/identity github.com/opencontainers/image-spec/specs-go