From e3feb05175ab9d5ee60fa5754d99d8f7ab45e7ce Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 17 Oct 2023 14:03:41 +0200 Subject: [PATCH 1/2] vendor: github.com/opencontainers/image-spec v1.1.0-rc5 full diff: https://github.com/opencontainers/image-spec/compare/v1.1.0-rc4...v1.1.0-rc5 Signed-off-by: Sebastiaan van Stijn --- vendor.mod | 2 +- vendor.sum | 4 ++-- .../opencontainers/image-spec/specs-go/v1/descriptor.go | 2 +- .../opencontainers/image-spec/specs-go/v1/layout.go | 6 +++++- .../opencontainers/image-spec/specs-go/version.go | 2 +- vendor/modules.txt | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/vendor.mod b/vendor.mod index 52bdcd38ed63f..bdd9bf4c1e669 100644 --- a/vendor.mod +++ b/vendor.mod @@ -76,7 +76,7 @@ require ( github.com/moby/term v0.5.0 github.com/morikuni/aec v1.0.0 github.com/opencontainers/go-digest v1.0.0 - github.com/opencontainers/image-spec v1.1.0-rc4 + github.com/opencontainers/image-spec v1.1.0-rc5 github.com/opencontainers/runc v1.1.9 github.com/opencontainers/runtime-spec v1.1.0 github.com/opencontainers/selinux v1.11.0 diff --git a/vendor.sum b/vendor.sum index 3e4b85c25c2b8..4c36e79434eed 100644 --- a/vendor.sum +++ b/vendor.sum @@ -996,8 +996,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.1.0-rc4 h1:oOxKUJWnFC4YGHCCMNql1x4YaDfYBTS5Y4x/Cgeo1E0= -github.com/opencontainers/image-spec v1.1.0-rc4/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= +github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.0-rc10/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.0-rc92/go.mod h1:X1zlU4p7wOlX4+WRCz+hvlRv8phdL7UqbYD+vQwNMmE= diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go b/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go index 3004e9a40dccc..1881b11814b0c 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/v1/descriptor.go @@ -21,7 +21,7 @@ import digest "github.com/opencontainers/go-digest" // when marshalled to JSON. type Descriptor struct { // MediaType is the media type of the object this schema refers to. - MediaType string `json:"mediaType,omitempty"` + MediaType string `json:"mediaType"` // Digest is the digest of the targeted content. Digest digest.Digest `json:"digest"` diff --git a/vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go b/vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go index fc79e9e0d140f..c5503cb3053b2 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/v1/layout.go @@ -15,10 +15,14 @@ package v1 const ( - // ImageLayoutFile is the file name of oci image layout file + // ImageLayoutFile is the file name containing ImageLayout in an OCI Image Layout ImageLayoutFile = "oci-layout" // ImageLayoutVersion is the version of ImageLayout ImageLayoutVersion = "1.0.0" + // ImageIndexFile is the file name of the entry point for references and descriptors in an OCI Image Layout + ImageIndexFile = "index.json" + // ImageBlobsDir is the directory name containing content addressable blobs in an OCI Image Layout + ImageBlobsDir = "blobs" ) // ImageLayout is the structure in the "oci-layout" file, found in the root 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 e3b7ac03a93d2..11e09b5846775 100644 --- a/vendor/github.com/opencontainers/image-spec/specs-go/version.go +++ b/vendor/github.com/opencontainers/image-spec/specs-go/version.go @@ -25,7 +25,7 @@ const ( VersionPatch = 0 // VersionDev indicates development branch. Releases will be empty string. - VersionDev = "-rc.4" + VersionDev = "-rc.5" ) // Version is the specification version that the package types support. diff --git a/vendor/modules.txt b/vendor/modules.txt index d51dbf011f035..ec57484e21bcc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -927,7 +927,7 @@ github.com/morikuni/aec ## explicit; go 1.13 github.com/opencontainers/go-digest github.com/opencontainers/go-digest/digestset -# github.com/opencontainers/image-spec v1.1.0-rc4 +# github.com/opencontainers/image-spec v1.1.0-rc5 ## explicit; go 1.18 github.com/opencontainers/image-spec/identity github.com/opencontainers/image-spec/specs-go From f05dce8d3a6dd270e373eb246f767c9668c84a51 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 17 Oct 2023 16:34:52 +0200 Subject: [PATCH 2/2] replace some strings with OCI consts Signed-off-by: Sebastiaan van Stijn --- image/tarexport/save.go | 15 ++++++++------- image/tarexport/tarexport.go | 4 ---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/image/tarexport/save.go b/image/tarexport/save.go index 2d4e7065a56e5..a962bea148b44 100644 --- a/image/tarexport/save.go +++ b/image/tarexport/save.go @@ -241,7 +241,7 @@ func (s *saveSession) save(outStream io.Writer) error { } dgst := digest.FromBytes(data) - mFile := filepath.Join(s.outDir, "blobs", dgst.Algorithm().String(), dgst.Encoded()) + mFile := filepath.Join(s.outDir, ocispec.ImageBlobsDir, dgst.Algorithm().String(), dgst.Encoded()) if err := os.MkdirAll(filepath.Dir(mFile), 0o755); err != nil { return errors.Wrap(err, "error creating blob directory") } @@ -279,11 +279,11 @@ func (s *saveSession) save(outStream io.Writer) error { for _, l := range imageDescr.layers { // IMPORTANT: We use path, not filepath here to ensure the layers // in the manifest use Unix-style forward-slashes. - layers = append(layers, path.Join("blobs", l.Algorithm().String(), l.Encoded())) + layers = append(layers, path.Join(ocispec.ImageBlobsDir, l.Algorithm().String(), l.Encoded())) } manifest = append(manifest, manifestItem{ - Config: path.Join("blobs", id.Digest().Algorithm().String(), id.Digest().Encoded()), + Config: path.Join(ocispec.ImageBlobsDir, id.Digest().Algorithm().String(), id.Digest().Encoded()), RepoTags: repoTags, Layers: layers, LayerSources: foreignSrcs, @@ -336,7 +336,8 @@ func (s *saveSession) save(outStream io.Writer) error { return err } - layoutPath := filepath.Join(tempDir, ociLayoutFilename) + const ociLayoutContent = `{"imageLayoutVersion": "` + ocispec.ImageLayoutVersion + `"}` + layoutPath := filepath.Join(tempDir, ocispec.ImageLayoutFile) if err := os.WriteFile(layoutPath, []byte(ociLayoutContent), 0o644); err != nil { return errors.Wrap(err, "error writing oci layout file") } @@ -355,7 +356,7 @@ func (s *saveSession) save(outStream io.Writer) error { return errors.Wrap(err, "error marshaling oci index") } - idxFile := filepath.Join(s.outDir, ociIndexFileName) + idxFile := filepath.Join(s.outDir, ocispec.ImageIndexFile) if err := os.WriteFile(idxFile, data, 0o644); err != nil { return errors.Wrap(err, "error writing oci index file") } @@ -420,7 +421,7 @@ func (s *saveSession) saveImage(id image.ID) (map[layer.DiffID]distribution.Desc data := img.RawJSON() dgst := digest.FromBytes(data) - blobDir := filepath.Join(s.outDir, "blobs", dgst.Algorithm().String()) + blobDir := filepath.Join(s.outDir, ocispec.ImageBlobsDir, dgst.Algorithm().String()) if err := os.MkdirAll(blobDir, 0o755); err != nil { return nil, err } @@ -452,7 +453,7 @@ func (s *saveSession) saveLayer(id layer.ChainID, legacyImg image.V1Image, creat return distribution.Descriptor{}, nil } - outDir := filepath.Join(s.outDir, "blobs") + outDir := filepath.Join(s.outDir, ocispec.ImageBlobsDir) imageConfig, err := json.Marshal(legacyImg) if err != nil { diff --git a/image/tarexport/tarexport.go b/image/tarexport/tarexport.go index ab3edc74a4d5f..e97398c2fa387 100644 --- a/image/tarexport/tarexport.go +++ b/image/tarexport/tarexport.go @@ -13,10 +13,6 @@ const ( legacyLayerFileName = "layer.tar" legacyConfigFileName = "json" legacyRepositoriesFileName = "repositories" - - ociIndexFileName = "index.json" - ociLayoutFilename = "oci-layout" - ociLayoutContent = `{"imageLayoutVersion": "1.0.0"}` ) type manifestItem struct {