Skip to content

Commit

Permalink
Merge pull request docker#4388 from thaJeztah/move_config_flag
Browse files Browse the repository at this point in the history
cli: move "config" flag to cli/flags/ClientOptions.InstallFlags()
  • Loading branch information
thaJeztah authored Jun 28, 2023
2 parents 3403f27 + 3cad05f commit d2b376d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cli/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

pluginmanager "github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
cliflags "github.com/docker/cli/cli/flags"
"github.com/docker/docker/pkg/homedir"
"github.com/docker/docker/registry"
Expand All @@ -24,10 +23,8 @@ import (
// setupCommonRootCommand contains the setup common to
// SetupRootCommand and SetupPluginRootCommand.
func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *pflag.FlagSet, *cobra.Command) {
opts := cliflags.NewClientOptions()
flags := rootCmd.Flags()

flags.StringVar(&opts.ConfigDir, "config", config.Dir(), "Location of client config files")
opts := cliflags.NewClientOptions()
opts.InstallFlags(flags)

cobra.AddTemplateFunc("add", func(a, b int) int { return a + b })
Expand Down
4 changes: 3 additions & 1 deletion cli/flags/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ func NewClientOptions() *ClientOptions {

// InstallFlags adds flags for the common options on the FlagSet
func (o *ClientOptions) InstallFlags(flags *pflag.FlagSet) {
configDir := config.Dir()
if dockerCertPath == "" {
dockerCertPath = config.Dir()
dockerCertPath = configDir
}

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

0 comments on commit d2b376d

Please sign in to comment.