Skip to content

Commit 5c4e3fc

Browse files
authored
Merge pull request #818 from crazy-max/fix-builder-flag
cli: fix builder persistent flag
2 parents 4c938c7 + eab0e6a commit 5c4e3fc

34 files changed

+277
-172
lines changed

commands/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/docker/buildx/driver"
1414
"github.com/docker/buildx/store"
1515
"github.com/docker/buildx/store/storeutil"
16+
"github.com/docker/buildx/util/cobrautil"
1617
"github.com/docker/cli/cli"
1718
"github.com/docker/cli/cli/command"
1819
"github.com/google/shlex"
@@ -238,7 +239,8 @@ func createCmd(dockerCli command.Cli) *cobra.Command {
238239
flags.BoolVar(&options.actionLeave, "leave", false, "Remove a node from builder instead of changing it")
239240
flags.BoolVar(&options.use, "use", false, "Set the current builder instance")
240241

241-
_ = flags
242+
// hide builder persistent flag for this command
243+
cobrautil.HideInheritedFlags(cmd, "builder")
242244

243245
return cmd
244246
}

commands/imagetools/create.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ func createCmd(dockerCli command.Cli, opts RootOptions) *cobra.Command {
261261
}
262262

263263
flags := cmd.Flags()
264-
265264
flags.StringArrayVarP(&options.files, "file", "f", []string{}, "Read source descriptor from file")
266265
flags.StringArrayVarP(&options.tags, "tag", "t", []string{}, "Set reference for new image")
267266
flags.BoolVar(&options.dryrun, "dry-run", false, "Show final image instead of pushing")

commands/imagetools/inspect.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func inspectCmd(dockerCli command.Cli, rootOpts RootOptions) *cobra.Command {
8585
}
8686

8787
flags := cmd.Flags()
88-
8988
flags.BoolVar(&options.raw, "raw", false, "Show original JSON manifest")
9089

9190
return cmd

commands/inspect.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ func inspectCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
132132
}
133133

134134
flags := cmd.Flags()
135-
136135
flags.BoolVar(&options.bootstrap, "bootstrap", false, "Ensure builder has booted before inspecting")
137136

138-
_ = flags
139-
140137
return cmd
141138
}

commands/install.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"os"
55

6+
"github.com/docker/buildx/util/cobrautil"
67
"github.com/docker/cli/cli"
78
"github.com/docker/cli/cli/command"
89
"github.com/docker/cli/cli/config"
@@ -48,5 +49,8 @@ func installCmd(dockerCli command.Cli) *cobra.Command {
4849
Hidden: true,
4950
}
5051

52+
// hide builder persistent flag for this command
53+
cobrautil.HideInheritedFlags(cmd, "builder")
54+
5155
return cmd
5256
}

commands/ls.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/docker/buildx/store"
1313
"github.com/docker/buildx/store/storeutil"
14+
"github.com/docker/buildx/util/cobrautil"
1415
"github.com/docker/buildx/util/platformutil"
1516
"github.com/docker/cli/cli"
1617
"github.com/docker/cli/cli/command"
@@ -148,5 +149,8 @@ func lsCmd(dockerCli command.Cli) *cobra.Command {
148149
},
149150
}
150151

152+
// hide builder persistent flag for this command
153+
cobrautil.HideInheritedFlags(cmd, "builder")
154+
151155
return cmd
152156
}

commands/stop.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ func stopCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
6262
},
6363
}
6464

65-
flags := cmd.Flags()
66-
67-
// flags.StringArrayVarP(&options.outputs, "output", "o", []string{}, "Output destination (format: type=local,dest=path)")
68-
69-
_ = flags
70-
7165
return cmd
7266
}
7367

commands/uninstall.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"os"
55

6+
"github.com/docker/buildx/util/cobrautil"
67
"github.com/docker/cli/cli"
78
"github.com/docker/cli/cli/command"
89
"github.com/docker/cli/cli/config"
@@ -54,5 +55,8 @@ func uninstallCmd(dockerCli command.Cli) *cobra.Command {
5455
Hidden: true,
5556
}
5657

58+
// hide builder persistent flag for this command
59+
cobrautil.HideInheritedFlags(cmd, "builder")
60+
5761
return cmd
5862
}

commands/use.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,8 @@ func useCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
8080
}
8181

8282
flags := cmd.Flags()
83-
8483
flags.BoolVar(&options.isGlobal, "global", false, "Builder persists context changes")
8584
flags.BoolVar(&options.isDefault, "default", false, "Set builder as default for current context")
8685

87-
_ = flags
88-
8986
return cmd
9087
}

commands/version.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"fmt"
55

6+
"github.com/docker/buildx/util/cobrautil"
67
"github.com/docker/buildx/version"
78
"github.com/docker/cli/cli"
89
"github.com/docker/cli/cli/command"
@@ -23,5 +24,9 @@ func versionCmd(dockerCli command.Cli) *cobra.Command {
2324
return runVersion(dockerCli)
2425
},
2526
}
27+
28+
// hide builder persistent flag for this command
29+
cobrautil.HideInheritedFlags(cmd, "builder")
30+
2631
return cmd
2732
}

0 commit comments

Comments
 (0)