From 09fcf8e3dd7082cdc67c484a725cf4e7593b23e7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 24 Sep 2025 12:10:57 +0200 Subject: [PATCH] cli/command: NewDockerCli: don't depend on DockerCli.Apply The Apply method was added when CLI options for constructing the CLI were rewritten into functional options in [cli@7f207f3]. There was no mention in the pull request of this method specifically, and this may have been related to work being done elsewhere on compose-on-kubernetes or the compose-cli plugin that may have needed options to modify the CLI config after it was already initialized. We should try to remove functions that mutate the CLI configuration after initialization if possible (and likely remove the `Apply` method); currently this function is used in docker compose, but as part of a hack that can probably be avoided. [cli@7f207f3]: https://github.com/docker/cli/commit/7f207f3f957ed3f5129aeb22bef2a429c14caf22 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 133279fb0d4adea30d27d27eb8789b79405fc82b) Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index b657ff313d..c62d6be3c4 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -603,8 +603,10 @@ func NewDockerCli(ops ...CLIOption) (*DockerCli, error) { ops = append(defaultOps, ops...) cli := &DockerCli{baseCtx: context.Background()} - if err := cli.Apply(ops...); err != nil { - return nil, err + for _, op := range ops { + if err := op(cli); err != nil { + return nil, err + } } return cli, nil }