From 9eceaa926f7111a4aaaeb99ca82bf2b2a83beacb Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Tue, 1 Nov 2016 22:01:16 +0800 Subject: [PATCH] Replace all "Filter" field with "Filters" for consistency In file `api/types/client.go`, some of the "*Options{}" structs own a `Filters` field while some else have the name of `Filter`, this commit will rename all `Filter` to `Filters` for consistency. Also `Filters` is consistent with API with format `/xxx?filters=xxx`, that's why `Filters` is the right name. Signed-off-by: Zhang Wei --- command/container/list.go | 8 ++++---- command/container/ps_test.go | 4 ++-- command/node/list.go | 2 +- command/node/ps.go | 2 +- command/service/list.go | 4 ++-- command/service/ps.go | 2 +- command/stack/common.go | 2 +- command/stack/list.go | 2 +- command/stack/ps.go | 2 +- command/stack/services.go | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/command/container/list.go b/command/container/list.go index 2d46b6604e..80de7c5ff4 100644 --- a/command/container/list.go +++ b/command/container/list.go @@ -79,10 +79,10 @@ func (p *preProcessor) Networks() bool { func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, error) { options := &types.ContainerListOptions{ - All: opts.all, - Limit: opts.last, - Size: opts.size, - Filter: opts.filter.Value(), + All: opts.all, + Limit: opts.last, + Size: opts.size, + Filters: opts.filter.Value(), } if opts.nLatest && opts.last == -1 { diff --git a/command/container/ps_test.go b/command/container/ps_test.go index dafdcdf905..9df4dfd5fa 100644 --- a/command/container/ps_test.go +++ b/command/container/ps_test.go @@ -55,10 +55,10 @@ func TestBuildContainerListOptions(t *testing.T) { assert.Equal(t, c.expectedAll, options.All) assert.Equal(t, c.expectedSize, options.Size) assert.Equal(t, c.expectedLimit, options.Limit) - assert.Equal(t, options.Filter.Len(), len(c.expectedFilters)) + assert.Equal(t, options.Filters.Len(), len(c.expectedFilters)) for k, v := range c.expectedFilters { - f := options.Filter + f := options.Filters if !f.ExactMatch(k, v) { t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k)) } diff --git a/command/node/list.go b/command/node/list.go index d028d19147..9cacdcf441 100644 --- a/command/node/list.go +++ b/command/node/list.go @@ -50,7 +50,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error { nodes, err := client.NodeList( ctx, - types.NodeListOptions{Filter: opts.filter.Value()}) + types.NodeListOptions{Filters: opts.filter.Value()}) if err != nil { return err } diff --git a/command/node/ps.go b/command/node/ps.go index 607488f35e..a034721d24 100644 --- a/command/node/ps.go +++ b/command/node/ps.go @@ -72,7 +72,7 @@ func runPs(dockerCli *command.DockerCli, opts psOptions) error { filter := opts.filter.Value() filter.Add("node", node.ID) - nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter}) + nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter}) if err != nil { errs = append(errs, err.Error()) continue diff --git a/command/service/list.go b/command/service/list.go index 2278643fbc..4db5618798 100644 --- a/command/service/list.go +++ b/command/service/list.go @@ -51,7 +51,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error { client := dockerCli.Client() out := dockerCli.Out() - services, err := client.ServiceList(ctx, types.ServiceListOptions{Filter: opts.filter.Value()}) + services, err := client.ServiceList(ctx, types.ServiceListOptions{Filters: opts.filter.Value()}) if err != nil { return err } @@ -63,7 +63,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error { taskFilter.Add("service", service.ID) } - tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: taskFilter}) + tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: taskFilter}) if err != nil { return err } diff --git a/command/service/ps.go b/command/service/ps.go index 55f837ba8e..cf94ad7374 100644 --- a/command/service/ps.go +++ b/command/service/ps.go @@ -64,7 +64,7 @@ func runPS(dockerCli *command.DockerCli, opts psOptions) error { } } - tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter}) + tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter}) if err != nil { return err } diff --git a/command/stack/common.go b/command/stack/common.go index 3e3a35faac..4776ec1b42 100644 --- a/command/stack/common.go +++ b/command/stack/common.go @@ -34,7 +34,7 @@ func getServices( ) ([]swarm.Service, error) { return apiclient.ServiceList( ctx, - types.ServiceListOptions{Filter: getStackFilter(namespace)}) + types.ServiceListOptions{Filters: getStackFilter(namespace)}) } func getNetworks( diff --git a/command/stack/list.go b/command/stack/list.go index 5d87cecb5f..f655b929ad 100644 --- a/command/stack/list.go +++ b/command/stack/list.go @@ -87,7 +87,7 @@ func getStacks( services, err := apiclient.ServiceList( ctx, - types.ServiceListOptions{Filter: filter}) + types.ServiceListOptions{Filters: filter}) if err != nil { return nil, err } diff --git a/command/stack/ps.go b/command/stack/ps.go index 2fff3de1fa..7a5e069cbe 100644 --- a/command/stack/ps.go +++ b/command/stack/ps.go @@ -56,7 +56,7 @@ func runPS(dockerCli *command.DockerCli, opts psOptions) error { filter.Add("desired-state", string(swarm.TaskStateAccepted)) } - tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: filter}) + tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter}) if err != nil { return err } diff --git a/command/stack/services.go b/command/stack/services.go index 50b50179de..1ca1c8c129 100644 --- a/command/stack/services.go +++ b/command/stack/services.go @@ -46,7 +46,7 @@ func runServices(dockerCli *command.DockerCli, opts servicesOptions) error { filter := opts.filter.Value() filter.Add("label", labelNamespace+"="+opts.namespace) - services, err := client.ServiceList(ctx, types.ServiceListOptions{Filter: filter}) + services, err := client.ServiceList(ctx, types.ServiceListOptions{Filters: filter}) if err != nil { return err } @@ -67,7 +67,7 @@ func runServices(dockerCli *command.DockerCli, opts servicesOptions) error { taskFilter.Add("service", service.ID) } - tasks, err := client.TaskList(ctx, types.TaskListOptions{Filter: taskFilter}) + tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: taskFilter}) if err != nil { return err }