Skip to content

Commit d2b376d

Browse files
authored
Merge pull request #4388 from thaJeztah/move_config_flag
cli: move "config" flag to cli/flags/ClientOptions.InstallFlags()
2 parents 3403f27 + 3cad05f commit d2b376d

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)