diff --git a/cli/cobra.go b/cli/cobra.go index d3ce7ff165..11d2fdc420 100644 --- a/cli/cobra.go +++ b/cli/cobra.go @@ -7,7 +7,7 @@ import ( pluginmanager "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/cli/command" - cliconfig "github.com/docker/cli/cli/config" + "github.com/docker/cli/cli/config" cliflags "github.com/docker/cli/cli/flags" "github.com/moby/term" "github.com/morikuni/aec" @@ -22,7 +22,7 @@ func setupCommonRootCommand(rootCmd *cobra.Command) (*cliflags.ClientOptions, *p opts := cliflags.NewClientOptions() flags := rootCmd.Flags() - flags.StringVar(&opts.ConfigDir, "config", cliconfig.Dir(), "Location of client config files") + flags.StringVar(&opts.ConfigDir, "config", config.Dir(), "Location of client config files") opts.Common.InstallFlags(flags) cobra.AddTemplateFunc("add", func(a, b int) int { return a + b }) diff --git a/cli/command/cli.go b/cli/command/cli.go index cfa43921b3..d4ba63b85f 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -11,7 +11,6 @@ import ( "time" "github.com/docker/cli/cli/config" - cliconfig "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" dcontext "github.com/docker/cli/cli/context" "github.com/docker/cli/cli/context/docker" @@ -129,7 +128,7 @@ func (cli *DockerCli) ConfigFile() *configfile.ConfigFile { } func (cli *DockerCli) loadConfigFile() { - cli.configFile = cliconfig.LoadDefaultConfigFile(cli.err) + cli.configFile = config.LoadDefaultConfigFile(cli.err) } // ServerInfo returns the server version details for the host this client is @@ -228,7 +227,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize cliflags.SetLogLevel(opts.Common.LogLevel) if opts.ConfigDir != "" { - cliconfig.SetDir(opts.ConfigDir) + config.SetDir(opts.ConfigDir) } if opts.Common.Debug { @@ -237,7 +236,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize cli.loadConfigFile() - baseContextStore := store.New(cliconfig.ContextStoreDir(), cli.contextStoreConfig) + baseContextStore := store.New(config.ContextStoreDir(), cli.contextStoreConfig) cli.contextStore = &ContextStoreWithDefault{ Store: baseContextStore, Resolver: func() (*DefaultContext, error) { @@ -272,7 +271,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize func NewAPIClientFromFlags(opts *cliflags.CommonOptions, configFile *configfile.ConfigFile) (client.APIClient, error) { storeConfig := DefaultContextStoreConfig() contextStore := &ContextStoreWithDefault{ - Store: store.New(cliconfig.ContextStoreDir(), storeConfig), + Store: store.New(config.ContextStoreDir(), storeConfig), Resolver: func() (*DefaultContext, error) { return ResolveDefaultContext(opts, configFile, storeConfig, io.Discard) }, diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 656f6e97ce..f87bc0877d 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -12,7 +12,7 @@ import ( "strings" "testing" - cliconfig "github.com/docker/cli/cli/config" + "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/cli/flags" "github.com/docker/docker/api" @@ -199,7 +199,7 @@ func TestExperimentalCLI(t *testing.T) { } cli := &DockerCli{client: apiclient, err: os.Stderr} - cliconfig.SetDir(dir.Path()) + config.SetDir(dir.Path()) err := cli.Initialize(flags.NewClientOptions()) assert.NilError(t, err) // For backward-compatibility, HasExperimental will always be "true" diff --git a/cli/flags/common.go b/cli/flags/common.go index a3bbf29571..cf2ccb59a8 100644 --- a/cli/flags/common.go +++ b/cli/flags/common.go @@ -5,7 +5,7 @@ import ( "os" "path/filepath" - cliconfig "github.com/docker/cli/cli/config" + "github.com/docker/cli/cli/config" "github.com/docker/cli/opts" "github.com/docker/go-connections/tlsconfig" "github.com/sirupsen/logrus" @@ -48,7 +48,7 @@ func NewCommonOptions() *CommonOptions { // InstallFlags adds flags for the common options on the FlagSet func (commonOpts *CommonOptions) InstallFlags(flags *pflag.FlagSet) { if dockerCertPath == "" { - dockerCertPath = cliconfig.Dir() + dockerCertPath = config.Dir() } flags.BoolVarP(&commonOpts.Debug, "debug", "D", false, "Enable debug mode") diff --git a/cli/flags/common_test.go b/cli/flags/common_test.go index 07edb41223..f248f8e9fc 100644 --- a/cli/flags/common_test.go +++ b/cli/flags/common_test.go @@ -4,7 +4,7 @@ import ( "path/filepath" "testing" - cliconfig "github.com/docker/cli/cli/config" + "github.com/docker/cli/cli/config" "github.com/spf13/pflag" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -27,7 +27,7 @@ func TestCommonOptionsInstallFlags(t *testing.T) { } func defaultPath(filename string) string { - return filepath.Join(cliconfig.Dir(), filename) + return filepath.Join(config.Dir(), filename) } func TestCommonOptionsInstallFlagsWithDefaults(t *testing.T) { diff --git a/cli/trust/trust.go b/cli/trust/trust.go index df11227e93..dda1c0bb59 100644 --- a/cli/trust/trust.go +++ b/cli/trust/trust.go @@ -12,7 +12,7 @@ import ( "path/filepath" "time" - cliconfig "github.com/docker/cli/cli/config" + "github.com/docker/cli/cli/config" "github.com/docker/distribution/reference" "github.com/docker/distribution/registry/client/auth" "github.com/docker/distribution/registry/client/auth/challenge" @@ -47,7 +47,7 @@ var ( // GetTrustDirectory returns the base trust directory name func GetTrustDirectory() string { - return filepath.Join(cliconfig.Dir(), "trust") + return filepath.Join(config.Dir(), "trust") } // certificateDirectory returns the directory containing @@ -59,7 +59,7 @@ func certificateDirectory(server string) (string, error) { return "", err } - return filepath.Join(cliconfig.Dir(), "tls", u.Host), nil + return filepath.Join(config.Dir(), "tls", u.Host), nil } // Server returns the base URL for the trust server.