Skip to content

Commit

Permalink
Merge pull request moby#46665 from thaJeztah/update_image_spec
Browse files Browse the repository at this point in the history
vendor: github.com/opencontainers/image-spec v1.1.0-rc5 and use OCI consts
  • Loading branch information
thaJeztah authored Oct 18, 2023
2 parents 1f96531 + f05dce8 commit 70589b8
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 18 deletions.
15 changes: 8 additions & 7 deletions image/tarexport/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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")
}
Expand All @@ -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")
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions image/tarexport/tarexport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion vendor.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions vendor.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 70589b8

Please sign in to comment.