Skip to content

Commit 3cad05f

Browse files
committed
cli: move "config" flag to cli/flags/ClientOptions.InstallFlags()
This flag was kept separate from the other flags, because at the time, the CLI code and Daemon code still used the same codebase, and shared some parts. This option only applied to the `docker` CLI, and thus was kept separate when migrating to Cobra in moby/moby@0452ff5 Now that this code is only used for the CLI (and plugins), we can move this flag together with the other flags. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 3403f27 commit 3cad05f

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

cli/cobra.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
pluginmanager "github.com/docker/cli/cli-plugins/manager"
1111
"github.com/docker/cli/cli/command"
12-
"github.com/docker/cli/cli/config"
1312
cliflags "github.com/docker/cli/cli/flags"
1413
"github.com/docker/docker/pkg/homedir"
1514
"github.com/docker/docker/registry"
@@ -24,10 +23,8 @@ import (
2423
// setupCommonRootCommand contains the setup common to
2524
// SetupRootCommand and SetupPluginRootCommand.
2625
func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *pflag.FlagSet, *cobra.Command) {
27-
opts := cliflags.NewClientOptions()
2826
flags := rootCmd.Flags()
29-
30-
flags.StringVar(&opts.ConfigDir, "config", config.Dir(), "Location of client config files")
27+
opts := cliflags.NewClientOptions()
3128
opts.InstallFlags(flags)
3229

3330
cobra.AddTemplateFunc("add", func(a, b int) int { return a + b })

cli/flags/options.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@ func NewClientOptions() *ClientOptions {
7373

7474
// InstallFlags adds flags for the common options on the FlagSet
7575
func (o *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
76+
configDir := config.Dir()
7677
if dockerCertPath == "" {
77-
dockerCertPath = config.Dir()
78+
dockerCertPath = configDir
7879
}
7980

81+
flags.StringVar(&o.ConfigDir, "config", configDir, "Location of client config files")
8082
flags.BoolVarP(&o.Debug, "debug", "D", false, "Enable debug mode")
8183
flags.StringVarP(&o.LogLevel, "log-level", "l", "info", `Set the logging level ("debug", "info", "warn", "error", "fatal")`)
8284
flags.BoolVar(&o.TLS, "tls", dockerTLS, "Use TLS; implied by --tlsverify")

0 commit comments

Comments
 (0)