Skip to content

Commit 65803ea

Browse files
gloursndeloof
authored andcommitted
remove error message from exec outpout by default
Add the error as a log for verbose mode Signed-off-by: Guillaume Lours <[email protected]>
1 parent f613379 commit 65803ea

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmd/compose/exec.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ package compose
1818

1919
import (
2020
"context"
21+
"errors"
2122
"fmt"
23+
"os"
2224

2325
"github.com/compose-spec/compose-go/v2/types"
2426
"github.com/docker/cli/cli"
2527
"github.com/docker/cli/cli/command"
2628
"github.com/docker/compose/v2/pkg/api"
2729
"github.com/docker/compose/v2/pkg/compose"
30+
"github.com/sirupsen/logrus"
2831
"github.com/spf13/cobra"
2932
)
3033

@@ -60,7 +63,15 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
6063
return nil
6164
}),
6265
RunE: Adapt(func(ctx context.Context, args []string) error {
63-
return runExec(ctx, dockerCli, backend, opts)
66+
err := runExec(ctx, dockerCli, backend, opts)
67+
if err != nil {
68+
logrus.Debugf("%v", err)
69+
var cliError cli.StatusError
70+
if ok := errors.As(err, &cliError); ok {
71+
os.Exit(err.(cli.StatusError).StatusCode) //nolint: errorlint
72+
}
73+
}
74+
return err
6475
}),
6576
ValidArgsFunction: completeServiceNames(dockerCli, p),
6677
}

0 commit comments

Comments
 (0)