cli/command: remove DockerCli.loadConfigFile()

This makes it more transparent what's happening.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-11-28 13:24:07 +01:00
parent 36441fc5f6
commit 181769f18c
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 3 additions and 6 deletions

View File

@ -132,16 +132,13 @@ func ShowHelp(err io.Writer) func(*cobra.Command, []string) error {
// ConfigFile returns the ConfigFile // ConfigFile returns the ConfigFile
func (cli *DockerCli) ConfigFile() *configfile.ConfigFile { func (cli *DockerCli) ConfigFile() *configfile.ConfigFile {
// TODO(thaJeztah): when would this happen? Is this only in tests (where cli.Initialize() is not called first?)
if cli.configFile == nil { if cli.configFile == nil {
cli.loadConfigFile() cli.configFile = config.LoadDefaultConfigFile(cli.err)
} }
return cli.configFile return cli.configFile
} }
func (cli *DockerCli) loadConfigFile() {
cli.configFile = config.LoadDefaultConfigFile(cli.err)
}
// ServerInfo returns the server version details for the host this client is // ServerInfo returns the server version details for the host this client is
// connected to // connected to
func (cli *DockerCli) ServerInfo() ServerInfo { func (cli *DockerCli) ServerInfo() ServerInfo {
@ -225,7 +222,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize
return errors.New("conflicting options: either specify --host or --context, not both") return errors.New("conflicting options: either specify --host or --context, not both")
} }
cli.loadConfigFile() cli.configFile = config.LoadDefaultConfigFile(cli.err)
baseContextStore := store.New(config.ContextStoreDir(), cli.contextStoreConfig) baseContextStore := store.New(config.ContextStoreDir(), cli.contextStoreConfig)
cli.contextStore = &ContextStoreWithDefault{ cli.contextStore = &ContextStoreWithDefault{