simplify signal handling for cobra context

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2024-01-19 16:44:30 -08:00
parent 650a7af0ae
commit 147c7135b0
16 changed files with 33 additions and 95 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/docker/buildx/builder"
"github.com/docker/buildx/store"
"github.com/docker/buildx/store/storeutil"
"github.com/docker/buildx/util/cobrautil"
"github.com/docker/buildx/util/cobrautil/completion"
"github.com/docker/cli/cli/command"
"github.com/pkg/errors"
@ -98,7 +97,7 @@ func rmCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
cmd := &cobra.Command{
Use: "rm [OPTIONS] [NAME] [NAME...]",
Short: "Remove one or more builder instances",
RunE: cobrautil.ConfigureContext(func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
options.builders = []string{rootOpts.builder}
if len(args) > 0 {
if options.allInactive {
@ -107,7 +106,7 @@ func rmCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
options.builders = args
}
return runRm(cmd.Context(), dockerCli, options)
}),
},
ValidArgsFunction: completion.BuilderNames(dockerCli),
}