vendor: github.com/moby/moby/api, moby/moby/client 7145e7666b8f (master)
full diff: - https://github.com/docker/docker/compare/api/v1.52.0-alpha.1...7145e7666b8f - https://github.com/docker/docker/compare/client/v0.1.0-alpha.0...7145e7666b8f Signed-off-by: Sebastiaan van Stijn <github@gone.nl> WIP latest Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -27,15 +27,15 @@ type fakeClient struct {
|
||||
removedSecrets []string
|
||||
removedConfigs []string
|
||||
|
||||
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
||||
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
|
||||
networkListFunc func(options client.NetworkListOptions) ([]network.Summary, error)
|
||||
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
||||
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
||||
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||
configListFunc func(options client.ConfigListOptions) ([]swarm.Config, error)
|
||||
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
|
||||
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
||||
|
||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||
|
||||
serviceRemoveFunc func(serviceID string) error
|
||||
networkRemoveFunc func(networkID string) error
|
||||
@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
|
||||
return cli.version
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
func (cli *fakeClient) ServiceList(_ context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
if cli.serviceListFunc != nil {
|
||||
return cli.serviceListFunc(options)
|
||||
}
|
||||
@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListO
|
||||
return servicesList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
|
||||
func (cli *fakeClient) NetworkList(_ context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
|
||||
if cli.networkListFunc != nil {
|
||||
return cli.networkListFunc(options)
|
||||
}
|
||||
@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(_ context.Context, options swarm.SecretListOpt
|
||||
return secretsList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
|
||||
func (cli *fakeClient) ConfigList(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
|
||||
if cli.configListFunc != nil {
|
||||
return cli.configListFunc(options)
|
||||
}
|
||||
@ -114,14 +114,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
|
||||
return configsList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
func (cli *fakeClient) TaskList(_ context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
if cli.taskListFunc != nil {
|
||||
return cli.taskListFunc(options)
|
||||
}
|
||||
return []swarm.Task{}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||
func (cli *fakeClient) NodeList(_ context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
|
||||
if cli.nodeListFunc != nil {
|
||||
return cli.nodeListFunc(options)
|
||||
}
|
||||
@ -135,7 +135,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
|
||||
return swarm.Node{}, nil, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
if cli.serviceUpdateFunc != nil {
|
||||
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
||||
}
|
||||
@ -179,7 +179,7 @@ func (cli *fakeClient) ConfigRemove(_ context.Context, configID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ client.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||
return swarm.Service{
|
||||
ID: serviceID,
|
||||
Spec: swarm.ServiceSpec{
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/golden"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestListErrors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
args []string
|
||||
flags map[string]string
|
||||
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
@ -32,14 +33,14 @@ func TestListErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
args: []string{},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{}, errors.New("error getting services")
|
||||
},
|
||||
expectedError: "error getting services",
|
||||
},
|
||||
{
|
||||
args: []string{},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service()}, nil
|
||||
},
|
||||
expectedError: "cannot get label",
|
||||
@ -114,7 +115,7 @@ func TestStackList(t *testing.T) {
|
||||
)
|
||||
}
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return services, nil
|
||||
},
|
||||
})
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -18,7 +19,7 @@ import (
|
||||
func TestStackPsErrors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
args []string
|
||||
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
@ -31,7 +32,7 @@ func TestStackPsErrors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
args: []string{"foo"},
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return nil, errors.New("error getting tasks")
|
||||
},
|
||||
expectedError: "error getting tasks",
|
||||
@ -54,7 +55,7 @@ func TestStackPsErrors(t *testing.T) {
|
||||
func TestStackPs(t *testing.T) {
|
||||
testCases := []struct {
|
||||
doc string
|
||||
taskListFunc func(swarm.TaskListOptions) ([]swarm.Task, error)
|
||||
taskListFunc func(client.TaskListOptions) ([]swarm.Task, error)
|
||||
nodeInspectWithRaw func(string) (swarm.Node, []byte, error)
|
||||
config configfile.ConfigFile
|
||||
args []string
|
||||
@ -69,7 +70,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithEmptyStack",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{}, nil
|
||||
},
|
||||
args: []string{"foo"},
|
||||
@ -77,7 +78,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithQuietOption",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(builders.TaskID("id-foo"))}, nil
|
||||
},
|
||||
args: []string{"foo"},
|
||||
@ -88,7 +89,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithNoTruncOption",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(builders.TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
|
||||
},
|
||||
args: []string{"foo"},
|
||||
@ -100,7 +101,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithNoResolveOption",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(
|
||||
builders.TaskNodeID("id-node-foo"),
|
||||
)}, nil
|
||||
@ -117,7 +118,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithFormat",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
||||
},
|
||||
args: []string{"foo"},
|
||||
@ -128,7 +129,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithConfigFormat",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
||||
},
|
||||
config: configfile.ConfigFile{
|
||||
@ -139,7 +140,7 @@ func TestStackPs(t *testing.T) {
|
||||
},
|
||||
{
|
||||
doc: "WithoutFormat",
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task(
|
||||
builders.TaskID("id-foo"),
|
||||
builders.TaskServiceID("service-id-foo"),
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/docker/cli/internal/test/builders"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/golden"
|
||||
@ -18,37 +19,37 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
testCases := []struct {
|
||||
args []string
|
||||
flags map[string]string
|
||||
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
|
||||
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
args: []string{"foo"},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return nil, errors.New("error getting services")
|
||||
},
|
||||
expectedError: "error getting services",
|
||||
},
|
||||
{
|
||||
args: []string{"foo"},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||
},
|
||||
nodeListFunc: func(options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||
nodeListFunc: func(options client.NodeListOptions) ([]swarm.Node, error) {
|
||||
return nil, errors.New("error getting nodes")
|
||||
},
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return []swarm.Task{*builders.Task()}, nil
|
||||
},
|
||||
expectedError: "error getting nodes",
|
||||
},
|
||||
{
|
||||
args: []string{"foo"},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||
},
|
||||
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
return nil, errors.New("error getting tasks")
|
||||
},
|
||||
expectedError: "error getting tasks",
|
||||
@ -58,7 +59,7 @@ func TestStackServicesErrors(t *testing.T) {
|
||||
flags: map[string]string{
|
||||
"format": "{{invalid format}}",
|
||||
},
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service()}, nil
|
||||
},
|
||||
expectedError: "template parsing error",
|
||||
@ -95,7 +96,7 @@ func TestRunServicesWithEmptyName(t *testing.T) {
|
||||
|
||||
func TestStackServicesEmptyServiceList(t *testing.T) {
|
||||
fakeCli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{}, nil
|
||||
},
|
||||
})
|
||||
@ -108,7 +109,7 @@ func TestStackServicesEmptyServiceList(t *testing.T) {
|
||||
|
||||
func TestStackServicesWithQuietOption(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service(builders.ServiceID("id-foo"))}, nil
|
||||
},
|
||||
})
|
||||
@ -121,7 +122,7 @@ func TestStackServicesWithQuietOption(t *testing.T) {
|
||||
|
||||
func TestStackServicesWithFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{
|
||||
*builders.Service(builders.ServiceName("service-name-foo")),
|
||||
}, nil
|
||||
@ -136,7 +137,7 @@ func TestStackServicesWithFormat(t *testing.T) {
|
||||
|
||||
func TestStackServicesWithConfigFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{
|
||||
*builders.Service(builders.ServiceName("service-name-foo")),
|
||||
}, nil
|
||||
@ -153,7 +154,7 @@ func TestStackServicesWithConfigFormat(t *testing.T) {
|
||||
|
||||
func TestStackServicesWithoutFormat(t *testing.T) {
|
||||
cli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{*builders.Service(
|
||||
builders.ServiceName("name-foo"),
|
||||
builders.ServiceID("id-foo"),
|
||||
|
||||
@ -27,15 +27,15 @@ type fakeClient struct {
|
||||
removedSecrets []string
|
||||
removedConfigs []string
|
||||
|
||||
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
||||
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
|
||||
networkListFunc func(options client.NetworkListOptions) ([]network.Summary, error)
|
||||
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
||||
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
||||
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||
configListFunc func(options client.ConfigListOptions) ([]swarm.Config, error)
|
||||
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
|
||||
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
|
||||
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
||||
|
||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||
|
||||
serviceRemoveFunc func(serviceID string) error
|
||||
networkRemoveFunc func(networkID string) error
|
||||
@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
|
||||
return cli.version
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
func (cli *fakeClient) ServiceList(_ context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
if cli.serviceListFunc != nil {
|
||||
return cli.serviceListFunc(options)
|
||||
}
|
||||
@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListO
|
||||
return servicesList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
|
||||
func (cli *fakeClient) NetworkList(_ context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
|
||||
if cli.networkListFunc != nil {
|
||||
return cli.networkListFunc(options)
|
||||
}
|
||||
@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(_ context.Context, options swarm.SecretListOpt
|
||||
return secretsList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
|
||||
func (cli *fakeClient) ConfigList(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
|
||||
if cli.configListFunc != nil {
|
||||
return cli.configListFunc(options)
|
||||
}
|
||||
@ -114,14 +114,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
|
||||
return configsList, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||
func (cli *fakeClient) TaskList(_ context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
|
||||
if cli.taskListFunc != nil {
|
||||
return cli.taskListFunc(options)
|
||||
}
|
||||
return []swarm.Task{}, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||
func (cli *fakeClient) NodeList(_ context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
|
||||
if cli.nodeListFunc != nil {
|
||||
return cli.nodeListFunc(options)
|
||||
}
|
||||
@ -135,7 +135,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
|
||||
return swarm.Node{}, nil, nil
|
||||
}
|
||||
|
||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
if cli.serviceUpdateFunc != nil {
|
||||
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
||||
}
|
||||
|
||||
@ -30,11 +30,11 @@ func getAllStacksFilter() filters.Args {
|
||||
}
|
||||
|
||||
func getStackServices(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Service, error) {
|
||||
return apiclient.ServiceList(ctx, swarm.ServiceListOptions{Filters: getStackFilter(namespace)})
|
||||
return apiclient.ServiceList(ctx, client.ServiceListOptions{Filters: getStackFilter(namespace)})
|
||||
}
|
||||
|
||||
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]network.Summary, error) {
|
||||
return apiclient.NetworkList(ctx, network.ListOptions{Filters: getStackFilter(namespace)})
|
||||
return apiclient.NetworkList(ctx, client.NetworkListOptions{Filters: getStackFilter(namespace)})
|
||||
}
|
||||
|
||||
func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Secret, error) {
|
||||
@ -42,9 +42,9 @@ func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace
|
||||
}
|
||||
|
||||
func getStackConfigs(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Config, error) {
|
||||
return apiclient.ConfigList(ctx, swarm.ConfigListOptions{Filters: getStackFilter(namespace)})
|
||||
return apiclient.ConfigList(ctx, client.ConfigListOptions{Filters: getStackFilter(namespace)})
|
||||
}
|
||||
|
||||
func getStackTasks(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Task, error) {
|
||||
return apiclient.TaskList(ctx, swarm.TaskListOptions{Filters: getStackFilter(namespace)})
|
||||
return apiclient.TaskList(ctx, client.TaskListOptions{Filters: getStackFilter(namespace)})
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ func validateExternalNetworks(ctx context.Context, apiClient client.NetworkAPICl
|
||||
// local-scoped networks, so there's no need to inspect them.
|
||||
continue
|
||||
}
|
||||
nw, err := apiClient.NetworkInspect(ctx, networkName, network.InspectOptions{})
|
||||
nw, err := apiClient.NetworkInspect(ctx, networkName, client.NetworkInspectOptions{})
|
||||
switch {
|
||||
case errdefs.IsNotFound(err):
|
||||
return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName)
|
||||
@ -220,7 +220,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
|
||||
if service, exists := existingServiceMap[name]; exists {
|
||||
_, _ = fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID)
|
||||
|
||||
updateOpts := swarm.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
updateOpts := client.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
|
||||
switch resolveImage {
|
||||
case ResolveImageAlways:
|
||||
@ -265,7 +265,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
|
||||
} else {
|
||||
_, _ = fmt.Fprintln(out, "Creating service", name)
|
||||
|
||||
createOpts := swarm.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
createOpts := client.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
|
||||
|
||||
// query registry if flag disabling it was not set
|
||||
if resolveImage == ResolveImageAlways || resolveImage == ResolveImageChanged {
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/docker/cli/internal/test/network"
|
||||
networktypes "github.com/moby/moby/api/types/network"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
@ -49,13 +50,13 @@ func TestValidateExternalNetworks(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testcase := range testcases {
|
||||
client := &network.FakeClient{
|
||||
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) {
|
||||
fakeAPIClient := &network.FakeClient{
|
||||
NetworkInspectFunc: func(_ context.Context, _ string, _ client.NetworkInspectOptions) (networktypes.Inspect, error) {
|
||||
return testcase.inspectResponse, testcase.inspectError
|
||||
},
|
||||
}
|
||||
networks := []string{testcase.network}
|
||||
err := validateExternalNetworks(context.Background(), client, networks)
|
||||
err := validateExternalNetworks(context.Background(), fakeAPIClient, networks)
|
||||
if testcase.expectedMsg == "" {
|
||||
assert.NilError(t, err)
|
||||
} else {
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/docker/cli/cli/compose/convert"
|
||||
"github.com/docker/cli/internal/test"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
)
|
||||
@ -32,12 +33,12 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
||||
namespace := convert.NewNamespace("mystack")
|
||||
|
||||
var (
|
||||
receivedOptions swarm.ServiceUpdateOptions
|
||||
receivedOptions client.ServiceUpdateOptions
|
||||
receivedService swarm.ServiceSpec
|
||||
)
|
||||
|
||||
client := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||
fakeCli := test.NewFakeCli(&fakeClient{
|
||||
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
|
||||
return []swarm.Service{
|
||||
{
|
||||
Spec: swarm.ServiceSpec{
|
||||
@ -55,7 +56,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||
receivedOptions = options
|
||||
receivedService = service
|
||||
return swarm.ServiceUpdateResponse{}, nil
|
||||
@ -97,14 +98,14 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err := deployServices(ctx, client, spec, namespace, false, ResolveImageChanged)
|
||||
_, err := deployServices(ctx, fakeCli, spec, namespace, false, ResolveImageChanged)
|
||||
assert.NilError(t, err)
|
||||
assert.Check(t, is.Equal(receivedOptions.QueryRegistry, tc.expectedQueryRegistry))
|
||||
assert.Check(t, is.Equal(receivedService.TaskTemplate.ContainerSpec.Image, tc.expectedImage))
|
||||
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, tc.expectedForceUpdate))
|
||||
|
||||
receivedService = swarm.ServiceSpec{}
|
||||
receivedOptions = swarm.ServiceUpdateOptions{}
|
||||
receivedOptions = client.ServiceUpdateOptions{}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/docker/cli/cli/command/stack/formatter"
|
||||
"github.com/docker/cli/cli/compose/convert"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -14,7 +13,7 @@ import (
|
||||
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
|
||||
services, err := apiClient.ServiceList(
|
||||
ctx,
|
||||
swarm.ServiceListOptions{Filters: getAllStacksFilter()})
|
||||
client.ServiceListOptions{Filters: getAllStacksFilter()})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ import (
|
||||
"github.com/docker/cli/cli/command/idresolver"
|
||||
"github.com/docker/cli/cli/command/stack/options"
|
||||
"github.com/docker/cli/cli/command/task"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// RunPS is the swarm implementation of docker stack ps
|
||||
@ -16,7 +16,7 @@ func RunPS(ctx context.Context, dockerCLI command.Cli, opts options.PS) error {
|
||||
filter := getStackFilterFromOpt(opts.Namespace, opts.Filter)
|
||||
|
||||
apiClient := dockerCLI.Client()
|
||||
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
|
||||
tasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -7,16 +7,17 @@ import (
|
||||
"github.com/docker/cli/cli/command/service"
|
||||
"github.com/docker/cli/cli/command/stack/options"
|
||||
"github.com/moby/moby/api/types/swarm"
|
||||
"github.com/moby/moby/client"
|
||||
)
|
||||
|
||||
// GetServices is the swarm implementation of listing stack services
|
||||
func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Services) ([]swarm.Service, error) {
|
||||
func GetServices(ctx context.Context, dockerCLI command.Cli, opts options.Services) ([]swarm.Service, error) {
|
||||
var (
|
||||
err error
|
||||
client = dockerCli.Client()
|
||||
err error
|
||||
apiClient = dockerCLI.Client()
|
||||
)
|
||||
|
||||
listOpts := swarm.ServiceListOptions{
|
||||
listOpts := client.ServiceListOptions{
|
||||
Filters: getStackFilterFromOpt(opts.Namespace, opts.Filter),
|
||||
// When not running "quiet", also get service status (number of running
|
||||
// and desired tasks). Note that this is only supported on API v1.41 and
|
||||
@ -25,7 +26,7 @@ func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
|
||||
Status: !opts.Quiet,
|
||||
}
|
||||
|
||||
services, err := client.ServiceList(ctx, listOpts)
|
||||
services, err := apiClient.ServiceList(ctx, listOpts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -43,7 +44,7 @@ func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
|
||||
// situations where the client uses the "default" version. To account for
|
||||
// these situations, we do a quick check for services that do not have
|
||||
// a ServiceStatus set, and perform a lookup for those.
|
||||
services, err = service.AppendServiceStatus(ctx, client, services)
|
||||
services, err = service.AppendServiceStatus(ctx, apiClient, services)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user