Skip to content

Commit a1ca46e

Browse files
authored
Merge pull request #3334 from glours/bump-compose-go-v2.8.0
bump compose-go to v2.8.0
2 parents 7d0efdc + 19304c0 commit a1ca46e

File tree

34 files changed

+11729
-31
lines changed

34 files changed

+11729
-31
lines changed

bake/compose.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
dockeropts "github.com/docker/cli/opts"
1818
"github.com/docker/go-units"
1919
"github.com/pkg/errors"
20-
"gopkg.in/yaml.v3"
20+
"go.yaml.in/yaml/v3"
2121
)
2222

2323
func ParseComposeFiles(fs []File) (*Config, error) {
@@ -151,6 +151,18 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
151151
return nil, err
152152
}
153153

154+
var inAttests []string
155+
if s.Build.SBOM != "" {
156+
inAttests = append(inAttests, buildflags.CanonicalizeAttest("sbom", s.Build.SBOM))
157+
}
158+
if s.Build.Provenance != "" {
159+
inAttests = append(inAttests, buildflags.CanonicalizeAttest("provenance", s.Build.Provenance))
160+
}
161+
attests, err := buildflags.ParseAttests(inAttests)
162+
if err != nil {
163+
return nil, err
164+
}
165+
154166
g.Targets = append(g.Targets, targetName)
155167
t := &Target{
156168
Name: targetName,
@@ -176,6 +188,7 @@ func ParseCompose(cfgs []composetypes.ConfigFile, envs map[string]string) (*Conf
176188
ShmSize: shmSize,
177189
Ulimits: ulimits,
178190
ExtraHosts: extraHosts,
191+
Attest: attests,
179192
}
180193
if err = t.composeExtTarget(s.Build.Extensions); err != nil {
181194
return nil, err

bake/compose_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,64 @@ func TestEmptyComposeFile(t *testing.T) {
977977
require.ErrorContains(t, err, `empty compose file`) // https://github.com/compose-spec/compose-go/blob/a42e7579d813e64c0c1f598a666358bc0c0a0eb4/loader/loader.go#L542
978978
}
979979

980+
func TestParseComposeAttests(t *testing.T) {
981+
dt := []byte(`
982+
services:
983+
app:
984+
build:
985+
context: .
986+
sbom: true
987+
provenance: mode=max
988+
`)
989+
990+
c, err := ParseCompose([]composetypes.ConfigFile{{Content: dt}}, nil)
991+
require.NoError(t, err)
992+
require.Equal(t, 1, len(c.Targets))
993+
994+
target := c.Targets[0]
995+
require.Equal(t, "app", target.Name)
996+
997+
require.NotNil(t, target.Attest)
998+
require.Len(t, target.Attest, 2)
999+
1000+
attestMap := target.Attest.ToMap()
1001+
require.Contains(t, attestMap, "sbom")
1002+
require.Contains(t, attestMap, "provenance")
1003+
1004+
// Check the actual content - sbom=true should result in disabled=false (not disabled)
1005+
require.Equal(t, "type=sbom", *attestMap["sbom"])
1006+
require.Equal(t, "type=provenance,mode=max", *attestMap["provenance"])
1007+
}
1008+
1009+
func TestParseComposeAttestsDisabled(t *testing.T) {
1010+
dt := []byte(`
1011+
services:
1012+
app:
1013+
build:
1014+
context: .
1015+
sbom: false
1016+
provenance: false
1017+
`)
1018+
1019+
c, err := ParseCompose([]composetypes.ConfigFile{{Content: dt}}, nil)
1020+
require.NoError(t, err)
1021+
require.Equal(t, 1, len(c.Targets))
1022+
1023+
target := c.Targets[0]
1024+
require.Equal(t, "app", target.Name)
1025+
1026+
require.NotNil(t, target.Attest)
1027+
require.Len(t, target.Attest, 2)
1028+
1029+
attestMap := target.Attest.ToMap()
1030+
require.Contains(t, attestMap, "sbom")
1031+
require.Contains(t, attestMap, "provenance")
1032+
1033+
// When disabled=true, the value should be nil
1034+
require.Nil(t, attestMap["sbom"])
1035+
require.Nil(t, attestMap["provenance"])
1036+
}
1037+
9801038
// chdir changes the current working directory to the named directory,
9811039
// and then restore the original working directory at the end of the test.
9821040
func chdir(t *testing.T, dir string) {

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/Masterminds/semver/v3 v3.4.0
77
github.com/Microsoft/go-winio v0.6.2
88
github.com/aws/aws-sdk-go-v2/config v1.27.27
9-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51 // main
9+
github.com/compose-spec/compose-go/v2 v2.8.0
1010
github.com/containerd/console v1.0.5
1111
github.com/containerd/containerd/v2 v2.1.3
1212
github.com/containerd/continuity v0.4.5
@@ -55,6 +55,7 @@ require (
5555
go.opentelemetry.io/otel/metric v1.35.0
5656
go.opentelemetry.io/otel/sdk v1.35.0
5757
go.opentelemetry.io/otel/trace v1.35.0
58+
go.yaml.in/yaml/v3 v3.0.4
5859
golang.org/x/mod v0.24.0
5960
golang.org/x/sync v0.14.0
6061
golang.org/x/sys v0.33.0
@@ -64,7 +65,6 @@ require (
6465
google.golang.org/grpc v1.72.2
6566
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
6667
google.golang.org/protobuf v1.36.6
67-
gopkg.in/yaml.v3 v3.0.1
6868
k8s.io/api v0.32.3
6969
k8s.io/apimachinery v0.32.3
7070
k8s.io/client-go v0.32.3
@@ -166,6 +166,7 @@ require (
166166
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
167167
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
168168
gopkg.in/inf.v0 v0.9.1 // indirect
169+
gopkg.in/yaml.v3 v3.0.1 // indirect
169170
k8s.io/klog/v2 v2.130.1 // indirect
170171
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
171172
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
6262
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA=
6363
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
6464
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4=
65-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51 h1:AjI75N9METifYMZK7eNt8XIgY9Sryv+1w3XDA7X2vZQ=
66-
github.com/compose-spec/compose-go/v2 v2.7.2-0.20250703132301-891fce532a51/go.mod h1:Zow/3eYNOnl2T4qLGZEizf8d/ht1qfy09G7WGOSzGOY=
65+
github.com/compose-spec/compose-go/v2 v2.8.0 h1:+xkrdBkyiiXY2gBTIhJvuKPH7zoC+jvlQBjah6Gg8+U=
66+
github.com/compose-spec/compose-go/v2 v2.8.0/go.mod h1:veko/VB7URrg/tKz3vmIAQDaz+CGiXH8vZsW79NmAww=
6767
github.com/containerd/cgroups/v3 v3.0.5 h1:44na7Ud+VwyE7LIoJ8JTNQOa549a8543BmzaJHo6Bzo=
6868
github.com/containerd/cgroups/v3 v3.0.5/go.mod h1:SA5DLYnXO8pTGYiAHXz94qvLQTKfVM5GEVisn4jpins=
6969
github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/qqsc=
@@ -441,6 +441,8 @@ go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU
441441
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
442442
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
443443
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
444+
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
445+
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
444446
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
445447
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
446448
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=

vendor/github.com/compose-spec/compose-go/v2/cli/options.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/compose-spec/compose-go/v2/dotenv/env.go

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/compose-spec/compose-go/v2/loader/loader.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/compose-spec/compose-go/v2/loader/reset.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/compose-spec/compose-go/v2/schema/compose-spec.json

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/compose-spec/compose-go/v2/template/variables.go

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)