cli/command: use shallower interface for completions
The completion functions only need the API-client, and not all of the CLI. However, passing the API-client as argument would mean that the API-client is initialized early, which may not be what we want, so instead, defining an APIClientProvider interface to preserve the behavior of initializing when needed only. While updating, also simplify stack.format to only require an io.Writer. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -3,16 +3,16 @@ package swarm
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/stack/formatter"
|
||||
"github.com/docker/cli/cli/compose/convert"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetStacks lists the swarm stacks.
|
||||
func GetStacks(ctx context.Context, dockerCli command.Cli) ([]*formatter.Stack, error) {
|
||||
services, err := dockerCli.Client().ServiceList(
|
||||
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
|
||||
services, err := apiClient.ServiceList(
|
||||
ctx,
|
||||
types.ServiceListOptions{Filters: getAllStacksFilter()})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user