From 4ecbb018f2919d35c28191d280c6995f0691c986 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:10:26 +0100 Subject: [PATCH 1/2] bump compose-go to v2.4.7 Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- .../compose-spec/compose-go/v2/loader/extends.go | 10 ++++++---- .../compose-spec/compose-go/v2/paths/resolve.go | 1 + .../compose-spec/compose-go/v2/paths/unix.go | 5 ++++- .../compose-spec/compose-go/v2/transform/canonical.go | 1 + vendor/modules.txt | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 444aacec..432d4316 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 github.com/Microsoft/go-winio v0.6.2 github.com/aws/aws-sdk-go-v2/config v1.26.6 - github.com/compose-spec/compose-go/v2 v2.4.6 + github.com/compose-spec/compose-go/v2 v2.4.7 github.com/containerd/console v1.0.4 github.com/containerd/containerd v1.7.24 github.com/containerd/continuity v0.4.5 diff --git a/go.sum b/go.sum index 168dca5d..844df472 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnTh github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE= github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb/go.mod h1:ZjrT6AXHbDs86ZSdt/osfBi5qfexBrKUdONk989Wnk4= -github.com/compose-spec/compose-go/v2 v2.4.6 h1:QiqXQ2L/f0OCbAl41bPpeiGAWVRIQ+GEDrYxO+dRPhQ= -github.com/compose-spec/compose-go/v2 v2.4.6/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc= +github.com/compose-spec/compose-go/v2 v2.4.7 h1:WNpz5bIbKG+G+w9pfu72B1ZXr+Og9jez8TMEo8ecXPk= +github.com/compose-spec/compose-go/v2 v2.4.7/go.mod h1:lFN0DrMxIncJGYAXTfWuajfwj5haBJqrBkarHcnjJKc= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0= github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0= diff --git a/vendor/github.com/compose-spec/compose-go/v2/loader/extends.go b/vendor/github.com/compose-spec/compose-go/v2/loader/extends.go index 2a127d2c..61051733 100644 --- a/vendor/github.com/compose-spec/compose-go/v2/loader/extends.go +++ b/vendor/github.com/compose-spec/compose-go/v2/loader/extends.go @@ -29,7 +29,7 @@ import ( // as we use another service definition by `extends`, we must exclude attributes which creates dependency to another service // see https://github.com/compose-spec/compose-spec/blob/main/05-services.md#restrictions -var exclusions = []string{"extends", "depends_on", "volumes_from"} +var exclusions = []string{"depends_on", "volumes_from"} func ApplyExtends(ctx context.Context, dict map[string]any, opts *Options, tracker *cycleTracker, post ...PostProcessor) error { a, ok := dict["services"] @@ -123,13 +123,15 @@ func applyServiceExtends(ctx context.Context, name string, services map[string]a }, }) } + for _, exclusion := range exclusions { + delete(source, exclusion) + } merged, err := override.ExtendService(source, service) if err != nil { return nil, err } - for _, exclusion := range exclusions { - delete(merged, exclusion) - } + + delete(merged, "extends") services[name] = merged return merged, nil } diff --git a/vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go b/vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go index 8bab0b43..c58cb410 100644 --- a/vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go +++ b/vendor/github.com/compose-spec/compose-go/v2/paths/resolve.go @@ -36,6 +36,7 @@ func ResolveRelativePaths(project map[string]any, base string, remotes []RemoteR r.resolvers = map[tree.Path]resolver{ "services.*.build.context": r.absContextPath, "services.*.build.additional_contexts.*": r.absContextPath, + "services.*.build.ssh.*": r.maybeUnixPath, "services.*.env_file.*.path": r.absPath, "services.*.label_file.*": r.absPath, "services.*.extends.file": r.absExtendsPath, diff --git a/vendor/github.com/compose-spec/compose-go/v2/paths/unix.go b/vendor/github.com/compose-spec/compose-go/v2/paths/unix.go index 5ab2616e..d47f9366 100644 --- a/vendor/github.com/compose-spec/compose-go/v2/paths/unix.go +++ b/vendor/github.com/compose-spec/compose-go/v2/paths/unix.go @@ -24,7 +24,10 @@ import ( ) func (r *relativePathsResolver) maybeUnixPath(a any) (any, error) { - p := a.(string) + p, ok := a.(string) + if !ok { + return a, nil + } p = ExpandUser(p) // Check if source is an absolute path (either Unix or Windows), to // handle a Windows client with a Unix daemon or vice-versa. diff --git a/vendor/github.com/compose-spec/compose-go/v2/transform/canonical.go b/vendor/github.com/compose-spec/compose-go/v2/transform/canonical.go index ff5bb37d..2ace976c 100644 --- a/vendor/github.com/compose-spec/compose-go/v2/transform/canonical.go +++ b/vendor/github.com/compose-spec/compose-go/v2/transform/canonical.go @@ -30,6 +30,7 @@ func init() { transformers["services.*.build.additional_contexts"] = transformKeyValue transformers["services.*.depends_on"] = transformDependsOn transformers["services.*.env_file"] = transformEnvFile + transformers["services.*.label_file"] = transformStringOrList transformers["services.*.extends"] = transformExtends transformers["services.*.networks"] = transformServiceNetworks transformers["services.*.volumes.*"] = transformVolumeMount diff --git a/vendor/modules.txt b/vendor/modules.txt index cd4dd1c5..95e5615c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -128,7 +128,7 @@ github.com/cenkalti/backoff/v4 # github.com/cespare/xxhash/v2 v2.3.0 ## explicit; go 1.11 github.com/cespare/xxhash/v2 -# github.com/compose-spec/compose-go/v2 v2.4.6 +# github.com/compose-spec/compose-go/v2 v2.4.7 ## explicit; go 1.21 github.com/compose-spec/compose-go/v2/cli github.com/compose-spec/compose-go/v2/consts From e762d3dbcab79bf0efef73e36cd569de2d72ffd2 Mon Sep 17 00:00:00 2001 From: Guillaume Lours <705411+glours@users.noreply.github.com> Date: Wed, 8 Jan 2025 11:44:27 +0100 Subject: [PATCH 2/2] update compose build ssh path to an absolute one the unit test doesn't define a working_dir so path generate on Windows is escaped this use case is already covered and tested by compose-go CI Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com> --- bake/compose_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bake/compose_test.go b/bake/compose_test.go index 277433a7..ebeb880e 100644 --- a/bake/compose_test.go +++ b/bake/compose_test.go @@ -33,7 +33,7 @@ services: cache_to: - type=local,dest=path/to/cache ssh: - - key=path/to/key + - key=/path/to/key - default secrets: - token @@ -77,7 +77,7 @@ secrets: require.Equal(t, []string{"type=local,src=path/to/cache"}, stringify(c.Targets[1].CacheFrom)) require.Equal(t, []string{"type=local,dest=path/to/cache"}, stringify(c.Targets[1].CacheTo)) require.Equal(t, "none", *c.Targets[1].NetworkMode) - require.Equal(t, []string{"default", "key=path/to/key"}, stringify(c.Targets[1].SSH)) + require.Equal(t, []string{"default", "key=/path/to/key"}, stringify(c.Targets[1].SSH)) require.Equal(t, []string{ "id=aws,src=/root/.aws/credentials", "id=token,env=ENV_TOKEN", @@ -283,7 +283,7 @@ services: tags: - ct-addon:baz ssh: - key: path/to/key + key: /path/to/key args: CT_ECR: foo CT_TAG: bar @@ -338,7 +338,7 @@ services: require.Equal(t, []string{"linux/amd64", "linux/arm64"}, c.Targets[0].Platforms) require.Equal(t, []string{"type=local,src=path/to/cache", "user/app:cache"}, stringify(c.Targets[0].CacheFrom)) require.Equal(t, []string{"type=local,dest=path/to/cache", "user/app:cache"}, stringify(c.Targets[0].CacheTo)) - require.Equal(t, []string{"default", "key=path/to/key", "other=path/to/otherkey"}, stringify(c.Targets[0].SSH)) + require.Equal(t, []string{"default", "key=/path/to/key", "other=path/to/otherkey"}, stringify(c.Targets[0].SSH)) require.Equal(t, newBool(true), c.Targets[0].Pull) require.Equal(t, map[string]string{"alpine": "docker-image://alpine:3.13"}, c.Targets[0].Contexts) require.Equal(t, []string{"ct-fake-aws:bar"}, c.Targets[1].Tags)