Skip to content

Commit

Permalink
[do not merge] test image-spec with embedded Platform
Browse files Browse the repository at this point in the history
testing "embed_platform" branch from opencontainers/image-spec#949

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Sep 9, 2022
1 parent abde08a commit 9b391e6
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 49 deletions.
3 changes: 0 additions & 3 deletions exporter/containerimage/image/docker_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,4 @@ type Image struct {

// Config defines the execution parameters which should be used as a base when running a container using the image.
Config ImageConfig `json:"config,omitempty"`

// Variant defines platform variant. To be added to OCI.
Variant string `json:"variant,omitempty"`
}
10 changes: 2 additions & 8 deletions exporter/containerimage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,7 @@ func defaultImageConfig() ([]byte, error) {
pl := platforms.Normalize(platforms.DefaultSpec())

img := ocispecs.Image{
Architecture: pl.Architecture,
OS: pl.OS,
Variant: pl.Variant,
Platform: pl,
}
img.RootFS.Type = "layers"
img.Config.WorkingDir = "/"
Expand All @@ -565,11 +563,7 @@ func defaultImageConfig() ([]byte, error) {

func attestationsConfig(layers []ocispecs.Descriptor) ([]byte, error) {
img := ocispecs.Image{
Architecture: intotoPlatform.Architecture,
OS: intotoPlatform.OS,
OSVersion: intotoPlatform.OSVersion,
OSFeatures: intotoPlatform.OSFeatures,
Variant: intotoPlatform.Variant,
Platform: intotoPlatform,
}
img.RootFS.Type = "layers"
for _, layer := range layers {
Expand Down
10 changes: 2 additions & 8 deletions frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,7 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
if img != nil {
ds.image = *img
if img.Architecture != "" && img.OS != "" {
ds.platform = &ocispecs.Platform{
OS: img.OS,
Architecture: img.Architecture,
Variant: img.Variant,
}
ds.platform = &img.Platform
}
}
if bi != nil {
Expand Down Expand Up @@ -606,9 +602,7 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
target.state = target.state.SetMarshalDefaults(defaults...)

if !platformOpt.implicitTarget {
target.image.OS = platformOpt.targetPlatform.OS
target.image.Architecture = platformOpt.targetPlatform.Architecture
target.image.Variant = platformOpt.targetPlatform.Variant
target.image.Platform = platformOpt.targetPlatform
}

return target, buildInfo, nil
Expand Down
4 changes: 1 addition & 3 deletions frontend/dockerfile/dockerfile2llb/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ func clone(src Image) Image {
func emptyImage(platform ocispecs.Platform) Image {
img := Image{
Image: ocispecs.Image{
Architecture: platform.Architecture,
OS: platform.OS,
Platform: platform,
},
Variant: platform.Variant,
}
img.RootFS.Type = "layers"
img.Config.WorkingDir = "/"
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/moby/sys/signal v0.7.0
github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 // FIXME: see replace
github.com/opencontainers/runc v1.1.3
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
github.com/opencontainers/selinux v1.10.1
Expand Down Expand Up @@ -151,3 +151,6 @@ require (
)

replace github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220831131523-b5a0d7a188ac+incompatible // 22.06 branch (v22.06-dev)

// FIXME: testing "embed_platform" branch from https://github.com/opencontainers/image-spec/pull/949
replace github.com/opencontainers/image-spec => github.com/thaJeztah/image-spec v1.0.2-0.20220908165244-ca2e500b1693
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1083,13 +1083,6 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ
github.com/opencontainers/go-digest v1.0.0-rc1.0.20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
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.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.20211117181255-693428a734f5/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 h1:9iFHD5Kt9hkOfeawBNiEeEaV7bmC4/Z5wJp8E9BptMs=
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1/go.mod h1:K/JAU0m27RFhDRX4PcFdIKntROP6y5Ed6O91aZYDQfs=
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-rc10/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
Expand Down Expand Up @@ -1305,6 +1298,8 @@ github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/tetafro/godot v0.4.2/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/thaJeztah/image-spec v1.0.2-0.20220908165244-ca2e500b1693 h1:UDwi6cyo6ZWVuQyc5sYN6PYdrjBwl42rr7TWvozuOEw=
github.com/thaJeztah/image-spec v1.0.2-0.20220908165244-ca2e500b1693/go.mod h1:K/JAU0m27RFhDRX4PcFdIKntROP6y5Ed6O91aZYDQfs=
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk=
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
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.

18 changes: 2 additions & 16 deletions vendor/github.com/opencontainers/image-spec/specs-go/v1/config.go

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.

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

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ github.com/morikuni/aec
# github.com/opencontainers/go-digest v1.0.0
## explicit; go 1.13
github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1
# github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1 => github.com/thaJeztah/image-spec v1.0.2-0.20220908165244-ca2e500b1693
## explicit; go 1.16
github.com/opencontainers/image-spec/identity
github.com/opencontainers/image-spec/specs-go
Expand Down Expand Up @@ -882,3 +882,4 @@ google.golang.org/protobuf/types/known/wrapperspb
## explicit
gopkg.in/yaml.v3
# github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220831131523-b5a0d7a188ac+incompatible
# github.com/opencontainers/image-spec => github.com/thaJeztah/image-spec v1.0.2-0.20220908165244-ca2e500b1693

0 comments on commit 9b391e6

Please sign in to comment.