Skip to content

Commit 21e45ff

Browse files
committed
cli/command: add WithAPIClient
This allows the cli to be initialized with a (custom) API client. Currently to be used for unit tests, but could be used for other scenarios. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 74874cd commit 21e45ff

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

cli/command/cli_options.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strconv"
77

88
"github.com/docker/cli/cli/streams"
9+
"github.com/docker/docker/client"
910
"github.com/moby/term"
1011
)
1112

@@ -86,3 +87,11 @@ func WithDefaultContextStoreConfig() DockerCliOption {
8687
return nil
8788
}
8889
}
90+
91+
// WithAPIClient configures the cli to use the given API client.
92+
func WithAPIClient(c client.APIClient) DockerCliOption {
93+
return func(cli *DockerCli) error {
94+
cli.client = c
95+
return nil
96+
}
97+
}

0 commit comments

Comments
 (0)