commands: make builder status timeouts configurable across cli flows
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
+5
-1
@@ -40,6 +40,7 @@ const (
|
||||
type lsOptions struct {
|
||||
format string
|
||||
noTrunc bool
|
||||
timeout time.Duration
|
||||
}
|
||||
|
||||
func runLs(ctx context.Context, dockerCli command.Cli, in lsOptions) error {
|
||||
@@ -60,7 +61,9 @@ func runLs(ctx context.Context, dockerCli command.Cli, in lsOptions) error {
|
||||
}
|
||||
|
||||
timeoutCtx, cancel := context.WithCancelCause(ctx)
|
||||
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, 20*time.Second, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||
if in.timeout > 0 {
|
||||
timeoutCtx, _ = context.WithTimeoutCause(timeoutCtx, in.timeout, errors.WithStack(context.DeadlineExceeded)) //nolint:govet // no need to manually cancel this context as we already rely on parent
|
||||
}
|
||||
defer func() { cancel(errors.WithStack(context.Canceled)) }()
|
||||
|
||||
eg, _ := errgroup.WithContext(timeoutCtx)
|
||||
@@ -114,6 +117,7 @@ func lsCmd(dockerCli command.Cli) *cobra.Command {
|
||||
flags := cmd.Flags()
|
||||
flags.StringVar(&options.format, "format", formatter.TableFormatKey, "Format the output")
|
||||
flags.BoolVar(&options.noTrunc, "no-trunc", false, "Don't truncate output")
|
||||
setBuilderStatusTimeoutFlag(flags, &options.timeout)
|
||||
|
||||
// hide builder persistent flag for this command
|
||||
cobrautil.HideInheritedFlags(cmd, "builder")
|
||||
|
||||
Reference in New Issue
Block a user