Skip to content

Commit 311a97a

Browse files
committed
cli/command: deprecate ResolveDefaultContext
The ResolveDefaultContext function was exported in [cli@f820766] to allow (unit) testing, but did not document that it was only exported for this purpose. The only external use of this function is in buildx, which uses it in a unit test that can be implemented without this function. This patch deprecates the function so that we can remove it. [cli@f820766]: f820766 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9c79528 commit 311a97a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cli/command/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...CLIOption)
254254
cli.contextStore = &ContextStoreWithDefault{
255255
Store: store.New(config.ContextStoreDir(), *cli.contextStoreConfig),
256256
Resolver: func() (*DefaultContext, error) {
257-
return ResolveDefaultContext(cli.options, *cli.contextStoreConfig)
257+
return resolveDefaultContext(cli.options, *cli.contextStoreConfig)
258258
},
259259
}
260260

@@ -291,7 +291,7 @@ func NewAPIClientFromFlags(opts *cliflags.ClientOptions, configFile *configfile.
291291
contextStore := &ContextStoreWithDefault{
292292
Store: store.New(config.ContextStoreDir(), storeConfig),
293293
Resolver: func() (*DefaultContext, error) {
294-
return ResolveDefaultContext(opts, storeConfig)
294+
return resolveDefaultContext(opts, storeConfig)
295295
},
296296
}
297297
endpoint, err := resolveDockerEndpoint(contextStore, resolveContextName(opts, configFile))

cli/command/defaultcontextstore.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ type EndpointDefaultResolver interface {
5454
}
5555

5656
// ResolveDefaultContext creates a Metadata for the current CLI invocation parameters
57+
//
58+
// Deprecated: this function is exported for testing and meant for internal use. It will be removed in the next release.
5759
func ResolveDefaultContext(opts *cliflags.ClientOptions, config store.Config) (*DefaultContext, error) {
60+
return resolveDefaultContext(opts, config)
61+
}
62+
63+
// resolveDefaultContext creates a Metadata for the current CLI invocation parameters
64+
func resolveDefaultContext(opts *cliflags.ClientOptions, config store.Config) (*DefaultContext, error) {
5865
contextTLSData := store.ContextTLSData{
5966
Endpoints: make(map[string]store.EndpointTLSData),
6067
}

cli/command/defaultcontextstore_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestDefaultContextInitializer(t *testing.T) {
5959
assert.NilError(t, err)
6060
t.Setenv("DOCKER_HOST", "ssh://someswarmserver")
6161
cli.configFile = &configfile.ConfigFile{}
62-
ctx, err := ResolveDefaultContext(&cliflags.ClientOptions{
62+
ctx, err := resolveDefaultContext(&cliflags.ClientOptions{
6363
TLS: true,
6464
TLSOptions: &tlsconfig.Options{
6565
CAFile: "./testdata/ca.pem",

0 commit comments

Comments
 (0)