From 4b0ec0d4ea5ead6230531f0b0956374e12778103 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 13 Jan 2026 14:27:34 +0100 Subject: [PATCH] cli/command: DockerCli: store API-client options as field Use a more generic "clientOptions" field to store options to apply when constructing the API client, instead of a dedicated field for user-agent. Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 5 ++--- cli/command/cli_options.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index b1e9453343a1..42d01b95644e 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -60,6 +60,7 @@ type Cli interface { type DockerCli struct { configFile *configfile.ConfigFile options *cliflags.ClientOptions + clientOpts []client.Opt in *streams.In out *streams.Out err *streams.Out @@ -72,7 +73,6 @@ type DockerCli struct { dockerEndpoint docker.Endpoint contextStoreConfig *store.Config initTimeout time.Duration - userAgent string res telemetryResource // baseCtx is the base context used for internal operations. In the future @@ -533,8 +533,7 @@ func (cli *DockerCli) initialize() error { return } if cli.client == nil { - ops := []client.Opt{client.WithUserAgent(cli.userAgent)} - if cli.client, cli.initErr = newAPIClientFromEndpoint(cli.dockerEndpoint, cli.configFile, ops...); cli.initErr != nil { + if cli.client, cli.initErr = newAPIClientFromEndpoint(cli.dockerEndpoint, cli.configFile, cli.clientOpts...); cli.initErr != nil { return } } diff --git a/cli/command/cli_options.go b/cli/command/cli_options.go index f787956c5b7e..8df4ae6b4f1d 100644 --- a/cli/command/cli_options.go +++ b/cli/command/cli_options.go @@ -221,7 +221,7 @@ func WithUserAgent(userAgent string) CLIOption { if userAgent == "" { return errors.New("user agent cannot be blank") } - cli.userAgent = userAgent + cli.clientOpts = append(cli.clientOpts, client.WithUserAgent(userAgent)) return nil } }