Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 843e5be

Browse files
Factorize pull flag between commands
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent 7d5ceb6 commit 843e5be

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

internal/commands/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
type inspectOptions struct {
1414
parametersOptions
1515
registryOptions
16-
pull bool
16+
pullOptions
1717
}
1818

1919
func inspectCmd(dockerCli command.Cli) *cobra.Command {
@@ -28,7 +28,7 @@ func inspectCmd(dockerCli command.Cli) *cobra.Command {
2828
}
2929
opts.parametersOptions.addFlags(cmd.Flags())
3030
opts.registryOptions.addFlags(cmd.Flags())
31-
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Pull the bundle")
31+
opts.pullOptions.addFlags(cmd.Flags())
3232
return cmd
3333
}
3434

internal/commands/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ type installOptions struct {
1717
parametersOptions
1818
credentialOptions
1919
registryOptions
20+
pullOptions
2021
orchestrator string
2122
kubeNamespace string
2223
stackName string
2324
sendRegistryAuth bool
24-
pull bool
2525
}
2626

2727
type nameKind uint
@@ -58,11 +58,11 @@ func installCmd(dockerCli command.Cli) *cobra.Command {
5858
opts.parametersOptions.addFlags(cmd.Flags())
5959
opts.credentialOptions.addFlags(cmd.Flags())
6060
opts.registryOptions.addFlags(cmd.Flags())
61+
opts.pullOptions.addFlags(cmd.Flags())
6162
cmd.Flags().StringVarP(&opts.orchestrator, "orchestrator", "o", "", "Orchestrator to install on (swarm, kubernetes)")
6263
cmd.Flags().StringVar(&opts.kubeNamespace, "kubernetes-namespace", "default", "Kubernetes namespace to install into")
6364
cmd.Flags().StringVar(&opts.stackName, "name", "", "Installation name (defaults to application name)")
6465
cmd.Flags().BoolVar(&opts.sendRegistryAuth, "with-registry-auth", false, "Sends registry auth")
65-
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Pull the bundle")
6666

6767
return cmd
6868
}

internal/commands/root.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ type registryOptions struct {
8282
func (o *registryOptions) addFlags(flags *pflag.FlagSet) {
8383
flags.StringSliceVar(&o.insecureRegistries, "insecure-registries", nil, "Use HTTP instead of HTTPS when pulling from/pushing to those registries")
8484
}
85+
86+
type pullOptions struct {
87+
pull bool
88+
}
89+
90+
func (o *pullOptions) addFlags(flags *pflag.FlagSet) {
91+
flags.BoolVar(&o.pull, "pull", false, "Pull the bundle")
92+
}

internal/commands/upgrade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ type upgradeOptions struct {
1515
parametersOptions
1616
credentialOptions
1717
registryOptions
18+
pullOptions
1819
bundleOrDockerApp string
19-
pull bool
2020
}
2121

2222
func upgradeCmd(dockerCli command.Cli) *cobra.Command {
@@ -32,8 +32,8 @@ func upgradeCmd(dockerCli command.Cli) *cobra.Command {
3232
opts.parametersOptions.addFlags(cmd.Flags())
3333
opts.credentialOptions.addFlags(cmd.Flags())
3434
opts.registryOptions.addFlags(cmd.Flags())
35+
opts.pullOptions.addFlags(cmd.Flags())
3536
cmd.Flags().StringVar(&opts.bundleOrDockerApp, "bundle", "", "Override with new bundle or Docker App")
36-
cmd.Flags().BoolVar(&opts.pull, "pull", false, "Pull the bundle")
3737

3838
return cmd
3939
}

0 commit comments

Comments
 (0)