mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
74874cd0c9
commit
21e45ff852
|
@ -6,6 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
|
"github.com/docker/docker/client"
|
||||||
"github.com/moby/term"
|
"github.com/moby/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,3 +87,11 @@ func WithDefaultContextStoreConfig() DockerCliOption {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithAPIClient configures the cli to use the given API client.
|
||||||
|
func WithAPIClient(c client.APIClient) DockerCliOption {
|
||||||
|
return func(cli *DockerCli) error {
|
||||||
|
cli.client = c
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue