From b0cb6406ff70416a8cc74638ab6a77a9d33b05fc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 18:09:10 +0200 Subject: [PATCH 1/2] cli/command: remove Apply from Cli interface The Apply command was deprecated in 24bfedf3f88762bcd46e6452d6547d838f780e6b, and has no known external users, but we didn't remove it from the interface. Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index f3012abe3e16..ee11d7009c4f 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -44,7 +44,6 @@ type Cli interface { Client() client.APIClient Streams SetIn(in *streams.In) - Apply(ops ...CLIOption) error config.Provider ServerInfo() ServerInfo CurrentVersion() string From 1b085a2b631823bb703eb77d8621b628b0e24b7e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 18:03:38 +0200 Subject: [PATCH 2/2] cli/command: remove deprecated 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. The CLI itself no longer depends on this method since [cli@133279f], and there are no known external users. It was deprecated in [cli@24bfedf], which is included in the 28.5.0 release, so we can remove it for 29.0. [cli@7f207f3]: https://github.com/docker/cli/commit/7f207f3f957ed3f5129aeb22bef2a429c14caf22 [cli@133279f]: https://github.com/docker/cli/commit/133279fb0d4adea30d27d27eb8789b79405fc82b [cli@24bfedf]: https://github.com/docker/cli/commit/24bfedf3f88762bcd46e6452d6547d838f780e6b Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 12 ------------ cli/command/cli_test.go | 23 ++++++++--------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index ee11d7009c4f..49f12a37b1c6 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -566,18 +566,6 @@ func (cli *DockerCli) initialize() error { return cli.initErr } -// Apply all the operation on the cli -// -// Deprecated: this method is no longer used and will be removed in the next release if there are no remaining users. -func (cli *DockerCli) Apply(ops ...CLIOption) error { - for _, op := range ops { - if err := op(cli); err != nil { - return err - } - } - return nil -} - // ServerInfo stores details about the supported features and platform of the // server type ServerInfo struct { diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 7990322fdeef..29f8c3e7ae61 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -255,8 +255,14 @@ func TestInitializeFromClientHangs(t *testing.T) { } func TestNewDockerCliAndOperators(t *testing.T) { - // Test default operations and also overriding default ones - cli, err := NewDockerCli(WithInputStream(io.NopCloser(strings.NewReader("some input")))) + outbuf := bytes.NewBuffer(nil) + errbuf := bytes.NewBuffer(nil) + + cli, err := NewDockerCli( + WithInputStream(io.NopCloser(strings.NewReader("some input"))), + WithOutputStream(outbuf), + WithErrorStream(errbuf), + ) assert.NilError(t, err) // Check streams are initialized assert.Check(t, cli.In() != nil) @@ -266,19 +272,6 @@ func TestNewDockerCliAndOperators(t *testing.T) { assert.NilError(t, err) assert.Equal(t, string(inputStream), "some input") - // Apply can modify a dockerCli after construction - outbuf := bytes.NewBuffer(nil) - errbuf := bytes.NewBuffer(nil) - err = cli.Apply( - WithInputStream(io.NopCloser(strings.NewReader("input"))), - WithOutputStream(outbuf), - WithErrorStream(errbuf), - ) - assert.NilError(t, err) - // Check input stream - inputStream, err = io.ReadAll(cli.In()) - assert.NilError(t, err) - assert.Equal(t, string(inputStream), "input") // Check output stream _, err = fmt.Fprint(cli.Out(), "output") assert.NilError(t, err)