Skip to content

Commit c8d190e

Browse files
authored
Merge branch 'main' into fix/publish-aborted-sentinel-error-v2
2 parents a09d4c1 + 3d2d03c commit c8d190e

8 files changed

Lines changed: 81 additions & 19 deletions

File tree

.github/workflows/pr-review.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ permissions:
1212

1313
jobs:
1414
review:
15+
if: >-
16+
github.event_name == 'issue_comment' ||
17+
github.event_name == 'pull_request_review_comment' ||
18+
github.event.pull_request.user.login != 'dependabot[bot]'
1519
uses: docker/cagent-action/.github/workflows/review-pr.yml@dba0ca51938c78afb363625363c50582243218d6 # v1.3.1
1620
# Scoped to the job so other jobs in this workflow aren't over-permissioned
1721
permissions:

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ require (
1313
github.com/containerd/containerd/v2 v2.2.2
1414
github.com/containerd/errdefs v1.0.0
1515
github.com/containerd/platforms v1.0.0-rc.3
16+
github.com/creack/pty v1.1.24
1617
github.com/distribution/reference v0.6.0
1718
github.com/docker/buildx v0.31.1
18-
github.com/docker/cli v29.2.1+incompatible
19+
github.com/docker/cli v29.3.1+incompatible
1920
github.com/docker/cli-docs-tool v0.11.0
2021
github.com/docker/docker v28.5.2+incompatible
2122
github.com/docker/go-units v0.5.0
@@ -24,7 +25,7 @@ require (
2425
github.com/go-viper/mapstructure/v2 v2.5.0
2526
github.com/google/go-cmp v0.7.0
2627
github.com/google/uuid v1.6.0
27-
github.com/hashicorp/go-version v1.8.0
28+
github.com/hashicorp/go-version v1.9.0
2829
github.com/jonboulle/clockwork v0.5.0
2930
github.com/mattn/go-shellwords v1.0.12
3031
github.com/mitchellh/go-ps v1.0.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK
8888
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
8989
github.com/docker/buildx v0.31.1 h1:zbvbrb9nxBNVV8nnI33f2F+4aAZBA1gY+AmeBFflMqY=
9090
github.com/docker/buildx v0.31.1/go.mod h1:SD+jYLnt3S4SXqohVtV+8z+dihnOgwMJ8t+bLQvsaCk=
91-
github.com/docker/cli v29.2.1+incompatible h1:n3Jt0QVCN65eiVBoUTZQM9mcQICCJt3akW4pKAbKdJg=
92-
github.com/docker/cli v29.2.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
91+
github.com/docker/cli v29.3.1+incompatible h1:M04FDj2TRehDacrosh7Vlkgc7AuQoWloQkf1PA5hmoI=
92+
github.com/docker/cli v29.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
9393
github.com/docker/cli-docs-tool v0.11.0 h1:7d8QARFb7QEobizqxmEM7fOteZEHwH/zWgHQtHZEcfE=
9494
github.com/docker/cli-docs-tool v0.11.0/go.mod h1:ma8BKiisUo8D6W05XEYIh3oa1UbgrZhi1nowyKFJa8Q=
9595
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
@@ -190,8 +190,8 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
190190
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
191191
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
192192
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
193-
github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4=
194-
github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
193+
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
194+
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
195195
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
196196
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
197197
github.com/in-toto/attestation v1.1.2 h1:MBFn6lsMq6dptQZJBhalXTcWMb/aJy3V+GX3VYj/V1E=

pkg/compose/build_bake.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,11 @@ func dockerFilePath(ctxName string, dockerfile string) string {
550550
if dockerfile == "" {
551551
return ""
552552
}
553-
if contextType, _ := build.DetectContextType(ctxName); contextType == build.ContextTypeGit {
553+
contextType, _ := build.DetectContextType(ctxName)
554+
if contextType == build.ContextTypeGit || contextType == build.ContextTypeRemote {
555+
return dockerfile
556+
}
557+
if strings.Contains(ctxName, "://") {
554558
return dockerfile
555559
}
556560
if !filepath.IsAbs(dockerfile) {

pkg/compose/build_test.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,58 @@ import (
2424
"gotest.tools/v3/assert"
2525
)
2626

27+
func Test_dockerFilePath(t *testing.T) {
28+
tests := []struct {
29+
name string
30+
ctxName string
31+
dockerfile string
32+
expected string
33+
}{
34+
{
35+
name: "empty dockerfile",
36+
ctxName: "/some/local/dir",
37+
dockerfile: "",
38+
expected: "",
39+
},
40+
{
41+
name: "local dir with relative dockerfile",
42+
ctxName: "/some/local/dir",
43+
dockerfile: "Dockerfile",
44+
expected: "/some/local/dir/Dockerfile",
45+
},
46+
{
47+
name: "local dir with absolute dockerfile",
48+
ctxName: "/some/local/dir",
49+
dockerfile: "/absolute/path/Dockerfile",
50+
expected: "/absolute/path/Dockerfile",
51+
},
52+
{
53+
name: "ssh URL preserves double slash",
54+
ctxName: "ssh://git@github.com:22/docker/welcome-to-docker.git",
55+
dockerfile: "Dockerfile",
56+
expected: "Dockerfile",
57+
},
58+
{
59+
name: "git:// URL returns dockerfile as-is",
60+
ctxName: "git://github.com/docker/compose.git",
61+
dockerfile: "Dockerfile",
62+
expected: "Dockerfile",
63+
},
64+
{
65+
name: "https git URL returns dockerfile as-is",
66+
ctxName: "https://github.com/docker/compose.git",
67+
dockerfile: "Dockerfile",
68+
expected: "Dockerfile",
69+
},
70+
}
71+
for _, tt := range tests {
72+
t.Run(tt.name, func(t *testing.T) {
73+
result := dockerFilePath(tt.ctxName, tt.dockerfile)
74+
assert.Equal(t, tt.expected, result)
75+
})
76+
}
77+
}
78+
2779
func Test_addBuildDependencies(t *testing.T) {
2880
project := &types.Project{Services: types.Services{
2981
"test": types.ServiceConfig{

pkg/compose/hook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (s composeService) runWaitExec(ctx context.Context, execID string, service
102102
TTY: service.Tty,
103103
})
104104
if err != nil {
105-
return nil
105+
return err
106106
}
107107

108108
// We miss a ContainerExecWait API

pkg/compose/hook_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !windows
2+
13
/*
24
Copyright 2020 Docker Compose CLI authors
35
@@ -22,7 +24,7 @@ import (
2224
"testing"
2325

2426
"github.com/compose-spec/compose-go/v2/types"
25-
"github.com/containerd/console"
27+
"github.com/creack/pty"
2628
"github.com/docker/cli/cli/streams"
2729
"github.com/moby/moby/api/types/container"
2830
"github.com/moby/moby/client"
@@ -67,16 +69,14 @@ func TestRunHook_ConsoleSize(t *testing.T) {
6769

6870
// Create a PTY so GetTtySize() returns real non-zero dimensions,
6971
// simulating an interactive terminal session.
70-
pty, slavePath, err := console.NewPty()
71-
assert.NilError(t, err)
72-
defer pty.Close() //nolint:errcheck
73-
assert.NilError(t, pty.Resize(console.WinSize{Height: 24, Width: 80}))
74-
75-
slaveFile, err := os.OpenFile(slavePath, os.O_RDWR, 0)
72+
ptmx, tty, err := pty.Open()
7673
assert.NilError(t, err)
77-
defer slaveFile.Close() //nolint:errcheck
78-
79-
mockCli.EXPECT().Out().Return(streams.NewOut(slaveFile)).AnyTimes()
74+
t.Cleanup(func() {
75+
_ = ptmx.Close()
76+
_ = tty.Close()
77+
})
78+
assert.NilError(t, pty.Setsize(ptmx, &pty.Winsize{Rows: 24, Cols: 80}))
79+
mockCli.EXPECT().Out().Return(streams.NewOut(tty)).AnyTimes()
8080

8181
service := types.ServiceConfig{
8282
Name: "test",

pkg/compose/publish.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ func (s *composeService) createLayers(ctx context.Context, project *types.Projec
197197
func processExtends(ctx context.Context, project *types.Project, extFiles map[string]string) ([]v1.Descriptor, error) {
198198
var layers []v1.Descriptor
199199
moreExtFiles := map[string]string{}
200+
envFiles := map[string]string{}
200201
for xf, hash := range extFiles {
201-
data, err := processFile(ctx, xf, project, moreExtFiles, nil)
202+
data, err := processFile(ctx, xf, project, moreExtFiles, envFiles)
202203
if err != nil {
203204
return nil, err
204205
}

0 commit comments

Comments
 (0)