mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
Add builder as a global flag.
This allows all subcommands to use this flag. Additionally reads the default value for the flag from the `BUILDX_BUILDER` env var. Precedence is: CLI ARG > flag > env var > config file Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@ -63,13 +63,12 @@ type buildOptions struct {
|
||||
}
|
||||
|
||||
type commonOptions struct {
|
||||
builderOptions
|
||||
builder string
|
||||
noCache *bool
|
||||
progress string
|
||||
pull *bool
|
||||
exportPush bool
|
||||
exportLoad bool
|
||||
builder string
|
||||
}
|
||||
|
||||
func runBuild(dockerCli command.Cli, in buildOptions) error {
|
||||
@ -210,7 +209,7 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, opts map[string]bu
|
||||
return err
|
||||
}
|
||||
|
||||
func buildCmd(dockerCli command.Cli) *cobra.Command {
|
||||
func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
|
||||
var options buildOptions
|
||||
|
||||
cmd := &cobra.Command{
|
||||
@ -220,6 +219,7 @@ func buildCmd(dockerCli command.Cli) *cobra.Command {
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
options.contextPath = args[0]
|
||||
options.builder = rootOpts.builder
|
||||
return runBuild(dockerCli, options)
|
||||
},
|
||||
}
|
||||
@ -305,7 +305,6 @@ func buildCmd(dockerCli command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
func commonBuildFlags(options *commonOptions, flags *pflag.FlagSet) {
|
||||
builderFlags(&options.builderOptions, flags)
|
||||
flags.Var(flagutil.Tristate(options.noCache), "no-cache", "Do not use cache when building the image")
|
||||
flags.StringVar(&options.progress, "progress", "auto", "Set type of progress output (auto, plain, tty). Use plain to show container output")
|
||||
flags.Var(flagutil.Tristate(options.pull), "pull", "Always attempt to pull a newer version of the image")
|
||||
|
Reference in New Issue
Block a user