mirror of https://github.com/docker/cli.git
cli/command: DockerCli: keep reference to options for later use
Store a reference to the options in the client, so that they are available for later use. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
181769f18c
commit
60987b8d7a
|
@ -69,6 +69,7 @@ type Cli interface {
|
||||||
// Instances of the client can be returned from NewDockerCli.
|
// Instances of the client can be returned from NewDockerCli.
|
||||||
type DockerCli struct {
|
type DockerCli struct {
|
||||||
configFile *configfile.ConfigFile
|
configFile *configfile.ConfigFile
|
||||||
|
options *cliflags.ClientOptions
|
||||||
in *streams.In
|
in *streams.In
|
||||||
out *streams.Out
|
out *streams.Out
|
||||||
err io.Writer
|
err io.Writer
|
||||||
|
@ -222,17 +223,16 @@ 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.options = opts
|
||||||
cli.configFile = config.LoadDefaultConfigFile(cli.err)
|
cli.configFile = config.LoadDefaultConfigFile(cli.err)
|
||||||
|
cli.currentContext = resolveContextName(cli.options, cli.configFile)
|
||||||
baseContextStore := store.New(config.ContextStoreDir(), cli.contextStoreConfig)
|
|
||||||
cli.contextStore = &ContextStoreWithDefault{
|
cli.contextStore = &ContextStoreWithDefault{
|
||||||
Store: baseContextStore,
|
Store: store.New(config.ContextStoreDir(), cli.contextStoreConfig),
|
||||||
Resolver: func() (*DefaultContext, error) {
|
Resolver: func() (*DefaultContext, error) {
|
||||||
return ResolveDefaultContext(opts, cli.contextStoreConfig)
|
return ResolveDefaultContext(cli.options, cli.contextStoreConfig)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cli.currentContext = resolveContextName(opts, cli.configFile)
|
cli.dockerEndpoint, err = resolveDockerEndpoint(cli.contextStore, resolveContextName(opts, cli.configFile))
|
||||||
cli.dockerEndpoint, err = resolveDockerEndpoint(cli.contextStore, cli.currentContext)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "unable to resolve docker endpoint")
|
return errors.Wrap(err, "unable to resolve docker endpoint")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue