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:
Brian Goff
2020-04-27 14:37:17 -07:00
parent 213d3af3b0
commit b2ec1d331c
10 changed files with 78 additions and 55 deletions

View File

@ -21,7 +21,7 @@ import (
)
type pruneOptions struct {
builderOptions
builder string
all bool
filter opts.FilterOpt
keepStorage opts.MemBytes
@ -124,7 +124,7 @@ func runPrune(dockerCli command.Cli, opts pruneOptions) error {
return nil
}
func pruneCmd(dockerCli command.Cli) *cobra.Command {
func pruneCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
options := pruneOptions{filter: opts.NewFilterOpt()}
cmd := &cobra.Command{
@ -132,6 +132,7 @@ func pruneCmd(dockerCli command.Cli) *cobra.Command {
Short: "Remove build cache ",
Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
options.builder = rootOpts.builder
return runPrune(dockerCli, options)
},
Annotations: map[string]string{"version": "1.00"},