Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions cli/command/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -567,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 {
Expand Down
23 changes: 8 additions & 15 deletions cli/command/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading