Skip to content

Commit

Permalink
Merge pull request #3657 from nalind/mediaType
Browse files Browse the repository at this point in the history
image: set MediaType in OCI manifests
  • Loading branch information
openshift-merge-robot committed Nov 30, 2021
2 parents 898db43 + 785b3bf commit fc4c263
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.17.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
github.com/opencontainers/image-spec v1.0.2-0.20211123152302-43a7dee1ec31
github.com/opencontainers/runc v1.0.2
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/runtime-tools v0.9.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,9 @@ 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.0.2-0.20210819154149-5ad6f50d6283 h1:TVzvdjOalkJBNkbpPVMAr4KV9QRf2IjfxdyxwAK78Gs=
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.2-0.20211123152302-43a7dee1ec31 h1:Wh4aR2I6JFwySre9m3iHJYuMnvUFE/HT6qAXozRWi/E=
github.com/opencontainers/image-spec v1.0.2-0.20211123152302-43a7dee1ec31/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
Expand Down
1 change: 1 addition & 0 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func (i *containerImageRef) createConfigsAndManifests() (v1.Image, v1.Manifest,
Versioned: specs.Versioned{
SchemaVersion: 2,
},
MediaType: v1.MediaTypeImageManifest,
Config: v1.Descriptor{
MediaType: v1.MediaTypeImageConfig,
},
Expand Down
1 change: 1 addition & 0 deletions internal/source/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func Create(ctx context.Context, sourcePath string, options CreateOptions) error
// Create and write the manifest.
manifest := specV1.Manifest{
Versioned: spec.Versioned{SchemaVersion: 2},
MediaType: specV1.MediaTypeImageManifest,
Config: specV1.Descriptor{
MediaType: MediaTypeSourceImageConfig,
Digest: configBlob.Digest,
Expand Down
1 change: 1 addition & 0 deletions pkg/blobcache/blobcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func TestBlobCache(t *testing.T) {
Versioned: specs.Versioned{
SchemaVersion: 2,
},
MediaType: v1.MediaTypeImageManifest,
Config: v1.Descriptor{
MediaType: v1.MediaTypeImageConfig,
Digest: configInfo.Digest,
Expand Down
2 changes: 1 addition & 1 deletion tests/imgtype/imgtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func main() {
errors = true
continue
}
manifestType = v1.MediaTypeImageManifest
manifestType = oManifest.MediaType
configType = oManifest.Config.MediaType
case define.Dockerv2ImageManifest:
err = json.Unmarshal(manifest, &dManifest)
Expand Down
6 changes: 4 additions & 2 deletions tests/source.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ load helpers
# Inspect the index.json
run jq -r .manifests[0].mediaType $srcdir/index.json
expect_output "application/vnd.oci.image.manifest.v1+json"
run jq -r .manifests[0].size $srcdir/index.json
expect_output "199"
run jq -r .mediaType $srcdir/index.json
expect_output null # TODO: common#839 will change this to "application/vnd.oci.image.index.v1+json"
# Digest of manifest
run jq -r .manifests[0].digest $srcdir/index.json
manifestDigest=${output//sha256:/} # strip off the sha256 prefix
Expand All @@ -25,6 +25,8 @@ load helpers
expect_output "null"
run jq -r .config.mediaType $srcdir/blobs/sha256/$manifestDigest
expect_output "application/vnd.oci.source.image.config.v1+json"
run jq -r .mediaType $srcdir/blobs/sha256/$manifestDigest
expect_output "application/vnd.oci.image.manifest.v1+json"
run jq -r .config.size $srcdir/blobs/sha256/$manifestDigest
[ "$status" -eq 0 ] # let's not check the size (afraid of time-stamp impacts)
# Digest of config
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 @@ -384,7 +384,7 @@ github.com/onsi/gomega/matchers/support/goraph/util
github.com/onsi/gomega/types
# github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
# github.com/opencontainers/image-spec v1.0.2-0.20211123152302-43a7dee1ec31
github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1
# github.com/opencontainers/runc v1.0.2
Expand Down

0 comments on commit fc4c263

Please sign in to comment.