Skip to content

Commit 23351ec

Browse files
committed
remove exit code per error type used by legacy metrics system
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 7c74076 commit 23351ec

File tree

9 files changed

+14
-228
lines changed

9 files changed

+14
-228
lines changed

cmd/compose/compose.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import (
4444
"github.com/docker/compose/v2/internal/experimental"
4545
"github.com/docker/compose/v2/internal/tracing"
4646
"github.com/docker/compose/v2/pkg/api"
47-
"github.com/docker/compose/v2/pkg/compose"
4847
ui "github.com/docker/compose/v2/pkg/progress"
4948
"github.com/docker/compose/v2/pkg/remote"
5049
"github.com/docker/compose/v2/pkg/utils"
@@ -121,17 +120,9 @@ func AdaptCmd(fn CobraCommand) func(cmd *cobra.Command, args []string) error {
121120
}()
122121

123122
err := fn(ctx, cmd, args)
124-
var composeErr compose.Error
125123
if api.IsErrCanceled(err) || errors.Is(ctx.Err(), context.Canceled) {
126124
err = dockercli.StatusError{
127125
StatusCode: 130,
128-
Status: compose.CanceledStatus,
129-
}
130-
}
131-
if errors.As(err, &composeErr) {
132-
err = dockercli.StatusError{
133-
StatusCode: composeErr.GetMetricsFailureCategory().ExitCode,
134-
Status: err.Error(),
135126
}
136127
}
137128
if ui.Mode == ui.ModeJSON {
@@ -307,7 +298,7 @@ func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, s
307298

308299
options, err := o.toProjectOptions(po...)
309300
if err != nil {
310-
return nil, metrics, compose.WrapComposeError(err)
301+
return nil, metrics, err
311302
}
312303

313304
options.WithListeners(func(event string, metadata map[string]any) {
@@ -339,7 +330,7 @@ func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, s
339330

340331
project, err := options.LoadProject(ctx)
341332
if err != nil {
342-
return nil, metrics, compose.WrapComposeError(err)
333+
return nil, metrics, err
343334
}
344335

345336
if project.Name == "" {
@@ -453,7 +444,7 @@ func RootCommand(dockerCli command.Cli, backend Backend) *cobra.Command { //noli
453444
}
454445
_ = cmd.Help()
455446
return dockercli.StatusError{
456-
StatusCode: compose.CommandSyntaxFailure.ExitCode,
447+
StatusCode: 1,
457448
Status: fmt.Sprintf("unknown docker command: %q", "compose "+args[0]),
458449
}
459450
},

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func pluginMain() {
6262

6363
cmd.SetFlagErrorFunc(func(c *cobra.Command, err error) error {
6464
return dockercli.StatusError{
65-
StatusCode: compose.CommandSyntaxFailure.ExitCode,
65+
StatusCode: 1,
6666
Status: err.Error(),
6767
}
6868
})

pkg/compose/build_buildkit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (s *composeService) doBuildBuildkit(ctx context.Context, service string, op
4848
confutil.NewConfig(s.dockerCli),
4949
buildx.WithPrefix(p, service, true))
5050
if err != nil {
51-
return "", WrapCategorisedComposeError(err, BuildFailure)
51+
return "", err
5252
}
5353
}
5454

pkg/compose/errors.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

pkg/compose/metrics.go

Lines changed: 0 additions & 79 deletions
This file was deleted.

pkg/compose/pull.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
211211
Text: "Warning",
212212
StatusText: getUnwrappedErrorMessage(err),
213213
})
214-
return "", WrapCategorisedComposeError(err, PullFailure)
214+
return "", err
215215
}
216216

217217
if err != nil {
@@ -221,7 +221,7 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
221221
Text: "Error",
222222
StatusText: getUnwrappedErrorMessage(err),
223223
})
224-
return "", WrapCategorisedComposeError(err, PullFailure)
224+
return "", err
225225
}
226226

227227
dec := json.NewDecoder(stream)
@@ -231,10 +231,10 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
231231
if errors.Is(err, io.EOF) {
232232
break
233233
}
234-
return "", WrapCategorisedComposeError(err, PullFailure)
234+
return "", err
235235
}
236236
if jm.Error != nil {
237-
return "", WrapCategorisedComposeError(errors.New(jm.Error.Message), PullFailure)
237+
return "", errors.New(jm.Error.Message)
238238
}
239239
if !quietPull {
240240
toPullProgressEvent(service.Name, jm, w)

pkg/e2e/build_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func TestBuildSSH(t *testing.T) {
174174
"--project-directory", "fixtures/build-test/ssh", "build", "--no-cache", "--ssh",
175175
"wrong-ssh=./fixtures/build-test/ssh/fake_rsa")
176176
res.Assert(t, icmd.Expected{
177-
ExitCode: 17,
177+
ExitCode: 1,
178178
Err: "unset ssh forward key fake-ssh",
179179
})
180180
})
@@ -304,7 +304,7 @@ func TestBuildPlatformsWithCorrectBuildxConfig(t *testing.T) {
304304
res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/build-test/platforms",
305305
"-f", "fixtures/build-test/platforms/compose-unsupported-platform.yml", "build")
306306
res.Assert(t, icmd.Expected{
307-
ExitCode: 17,
307+
ExitCode: 1,
308308
Err: "no match for platform in",
309309
})
310310
})
@@ -402,7 +402,7 @@ func TestBuildPlatformsStandardErrors(t *testing.T) {
402402
t.Run("builder does not support multi-arch", func(t *testing.T) {
403403
res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/build-test/platforms", "build")
404404
res.Assert(t, icmd.Expected{
405-
ExitCode: 17,
405+
ExitCode: 1,
406406
Err: `Multi-platform build is not supported for the docker driver.
407407
Switch to a different driver, or turn on the containerd image store, and try again.`,
408408
})
@@ -412,7 +412,7 @@ Switch to a different driver, or turn on the containerd image store, and try aga
412412
res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/build-test/platforms",
413413
"-f", "fixtures/build-test/platforms/compose-service-platform-not-in-build-platforms.yaml", "build")
414414
res.Assert(t, icmd.Expected{
415-
ExitCode: 15,
415+
ExitCode: 1,
416416
Err: `service.build.platforms MUST include service.platform "linux/riscv64"`,
417417
})
418418
})

pkg/e2e/metrics_test.go

Lines changed: 0 additions & 55 deletions
This file was deleted.

pkg/e2e/pull_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func TestComposePull(t *testing.T) {
8282

8383
t.Run("Verify pull failure", func(t *testing.T) {
8484
res := c.RunDockerComposeCmdNoCheck(t, "--project-directory", "fixtures/compose-pull/unknown-image", "pull")
85-
res.Assert(t, icmd.Expected{ExitCode: 18, Err: "pull access denied for does_not_exists"})
85+
res.Assert(t, icmd.Expected{ExitCode: 1, Err: "pull access denied for does_not_exists"})
8686
})
8787

8888
t.Run("Verify ignore pull failure", func(t *testing.T) {

0 commit comments

Comments
 (0)