From 04b44b3a89d7f0284553875119c565561c550d7c Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Wed, 13 Apr 2022 14:36:48 +0100 Subject: [PATCH] imagetools: respect --builder flag The --builder flag was being ignored by imagetools because of pointer problems. Essentially, because the root cmds aren't parsed immediately, we need to pass a pointer to the builder string so that it can be updated before the RunE function gets called. Signed-off-by: Justin Chadwell --- commands/imagetools/create.go | 2 +- commands/imagetools/inspect.go | 2 +- commands/imagetools/root.go | 2 +- commands/root.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/imagetools/create.go b/commands/imagetools/create.go index 3f19e204..7a75d2c7 100644 --- a/commands/imagetools/create.go +++ b/commands/imagetools/create.go @@ -255,7 +255,7 @@ func createCmd(dockerCli command.Cli, opts RootOptions) *cobra.Command { Use: "create [OPTIONS] [SOURCE] [SOURCE...]", Short: "Create a new image based on source images", RunE: func(cmd *cobra.Command, args []string) error { - options.builder = opts.Builder + options.builder = *opts.Builder return runCreate(dockerCli, options, args) }, } diff --git a/commands/imagetools/inspect.go b/commands/imagetools/inspect.go index 7efc648c..7e859709 100644 --- a/commands/imagetools/inspect.go +++ b/commands/imagetools/inspect.go @@ -66,7 +66,7 @@ func inspectCmd(dockerCli command.Cli, rootOpts RootOptions) *cobra.Command { Short: "Show details of an image in the registry", Args: cli.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - options.builder = rootOpts.Builder + options.builder = *rootOpts.Builder return runInspect(dockerCli, options, args[0]) }, } diff --git a/commands/imagetools/root.go b/commands/imagetools/root.go index 9be5b013..6c6ede2f 100644 --- a/commands/imagetools/root.go +++ b/commands/imagetools/root.go @@ -6,7 +6,7 @@ import ( ) type RootOptions struct { - Builder string + Builder *string } func RootCmd(dockerCli command.Cli, opts RootOptions) *cobra.Command { diff --git a/commands/root.go b/commands/root.go index bed7dece..100e6790 100644 --- a/commands/root.go +++ b/commands/root.go @@ -74,7 +74,7 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) { versionCmd(dockerCli), pruneCmd(dockerCli, opts), duCmd(dockerCli, opts), - imagetoolscmd.RootCmd(dockerCli, imagetoolscmd.RootOptions{Builder: opts.builder}), + imagetoolscmd.RootCmd(dockerCli, imagetoolscmd.RootOptions{Builder: &opts.builder}), ) }