From 0d82ff4ae1e40dd158427e6598fccf89fea20062 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 16 May 2025 23:20:18 +0200 Subject: [PATCH] cli/command: move WithInitializeClient to other options Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 9 --------- cli/command/cli_options.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 7b2bb63b58..b78525bc82 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -222,15 +222,6 @@ func (cli *DockerCli) HooksEnabled() bool { return false } -// WithInitializeClient is passed to DockerCli.Initialize by callers who wish to set a particular API Client for use by the CLI. -func WithInitializeClient(makeClient func(dockerCli *DockerCli) (client.APIClient, error)) CLIOption { - return func(dockerCli *DockerCli) error { - var err error - dockerCli.client, err = makeClient(dockerCli) - return err - } -} - // Initialize the dockerCli runs initialization that must happen after command // line flags are parsed. func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...CLIOption) error { diff --git a/cli/command/cli_options.go b/cli/command/cli_options.go index 5d0a8ee3a6..0ea56533b1 100644 --- a/cli/command/cli_options.go +++ b/cli/command/cli_options.go @@ -114,6 +114,16 @@ func WithAPIClient(c client.APIClient) CLIOption { } } +// WithInitializeClient is passed to [DockerCli.Initialize] to initialize +// an API Client for use by the CLI. +func WithInitializeClient(makeClient func(*DockerCli) (client.APIClient, error)) CLIOption { + return func(cli *DockerCli) error { + var err error + cli.client, err = makeClient(cli) + return err + } +} + // envOverrideHTTPHeaders is the name of the environment-variable that can be // used to set custom HTTP headers to be sent by the client. This environment // variable is the equivalent to the HttpHeaders field in the configuration