1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #27948 from WeiZhang555/consistent-filters

Replace all "Filter" field with "Filters" for consistency
This commit is contained in:
Sebastiaan van Stijn 2016-11-02 00:53:15 -07:00 committed by GitHub
commit f96d45dc8a
23 changed files with 55 additions and 55 deletions

View file

@ -32,11 +32,11 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response
} }
config := &types.ContainerListOptions{ config := &types.ContainerListOptions{
All: httputils.BoolValue(r, "all"), All: httputils.BoolValue(r, "all"),
Size: httputils.BoolValue(r, "size"), Size: httputils.BoolValue(r, "size"),
Since: r.Form.Get("since"), Since: r.Form.Get("since"),
Before: r.Form.Get("before"), Before: r.Form.Get("before"),
Filter: filter, Filters: filter,
} }
if tmpLimit := r.Form.Get("limit"); tmpLimit != "" { if tmpLimit := r.Form.Get("limit"); tmpLimit != "" {

View file

@ -102,7 +102,7 @@ func (sr *swarmRouter) getServices(ctx context.Context, w http.ResponseWriter, r
return err return err
} }
services, err := sr.backend.GetServices(basictypes.ServiceListOptions{Filter: filter}) services, err := sr.backend.GetServices(basictypes.ServiceListOptions{Filters: filter})
if err != nil { if err != nil {
logrus.Errorf("Error getting services: %v", err) logrus.Errorf("Error getting services: %v", err)
return err return err
@ -182,7 +182,7 @@ func (sr *swarmRouter) getNodes(ctx context.Context, w http.ResponseWriter, r *h
return err return err
} }
nodes, err := sr.backend.GetNodes(basictypes.NodeListOptions{Filter: filter}) nodes, err := sr.backend.GetNodes(basictypes.NodeListOptions{Filters: filter})
if err != nil { if err != nil {
logrus.Errorf("Error getting nodes: %v", err) logrus.Errorf("Error getting nodes: %v", err)
return err return err
@ -243,7 +243,7 @@ func (sr *swarmRouter) getTasks(ctx context.Context, w http.ResponseWriter, r *h
return err return err
} }
tasks, err := sr.backend.GetTasks(basictypes.TaskListOptions{Filter: filter}) tasks, err := sr.backend.GetTasks(basictypes.TaskListOptions{Filters: filter})
if err != nil { if err != nil {
logrus.Errorf("Error getting tasks: %v", err) logrus.Errorf("Error getting tasks: %v", err)
return err return err

View file

@ -59,14 +59,14 @@ type ContainerExecInspect struct {
// ContainerListOptions holds parameters to list containers with. // ContainerListOptions holds parameters to list containers with.
type ContainerListOptions struct { type ContainerListOptions struct {
Quiet bool Quiet bool
Size bool Size bool
All bool All bool
Latest bool Latest bool
Since string Since string
Before string Before string
Limit int Limit int
Filter filters.Args Filters filters.Args
} }
// ContainerLogsOptions holds parameters to filter logs with. // ContainerLogsOptions holds parameters to filter logs with.
@ -267,7 +267,7 @@ func (v VersionResponse) ServerOK() bool {
// NodeListOptions holds parameters to list nodes with. // NodeListOptions holds parameters to list nodes with.
type NodeListOptions struct { type NodeListOptions struct {
Filter filters.Args Filters filters.Args
} }
// NodeRemoveOptions holds parameters to remove nodes with. // NodeRemoveOptions holds parameters to remove nodes with.
@ -317,12 +317,12 @@ type ServiceUpdateOptions struct {
// ServiceListOptions holds parameters to list services with. // ServiceListOptions holds parameters to list services with.
type ServiceListOptions struct { type ServiceListOptions struct {
Filter filters.Args Filters filters.Args
} }
// TaskListOptions holds parameters to list tasks with. // TaskListOptions holds parameters to list tasks with.
type TaskListOptions struct { type TaskListOptions struct {
Filter filters.Args Filters filters.Args
} }
// PluginRemoveOptions holds parameters to remove plugins. // PluginRemoveOptions holds parameters to remove plugins.

View file

@ -79,10 +79,10 @@ func (p *preProcessor) Networks() bool {
func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, error) { func buildContainerListOptions(opts *psOptions) (*types.ContainerListOptions, error) {
options := &types.ContainerListOptions{ options := &types.ContainerListOptions{
All: opts.all, All: opts.all,
Limit: opts.last, Limit: opts.last,
Size: opts.size, Size: opts.size,
Filter: opts.filter.Value(), Filters: opts.filter.Value(),
} }
if opts.nLatest && opts.last == -1 { if opts.nLatest && opts.last == -1 {

View file

@ -55,10 +55,10 @@ func TestBuildContainerListOptions(t *testing.T) {
assert.Equal(t, c.expectedAll, options.All) assert.Equal(t, c.expectedAll, options.All)
assert.Equal(t, c.expectedSize, options.Size) assert.Equal(t, c.expectedSize, options.Size)
assert.Equal(t, c.expectedLimit, options.Limit) 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 { for k, v := range c.expectedFilters {
f := options.Filter f := options.Filters
if !f.ExactMatch(k, v) { if !f.ExactMatch(k, v) {
t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k)) t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k))
} }

View file

@ -50,7 +50,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error {
nodes, err := client.NodeList( nodes, err := client.NodeList(
ctx, ctx,
types.NodeListOptions{Filter: opts.filter.Value()}) types.NodeListOptions{Filters: opts.filter.Value()})
if err != nil { if err != nil {
return err return err
} }

View file

@ -72,7 +72,7 @@ func runPs(dockerCli *command.DockerCli, opts psOptions) error {
filter := opts.filter.Value() filter := opts.filter.Value()
filter.Add("node", node.ID) 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 { if err != nil {
errs = append(errs, err.Error()) errs = append(errs, err.Error())
continue continue

View file

@ -51,7 +51,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error {
client := dockerCli.Client() client := dockerCli.Client()
out := dockerCli.Out() 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 { if err != nil {
return err return err
} }
@ -63,7 +63,7 @@ func runList(dockerCli *command.DockerCli, opts listOptions) error {
taskFilter.Add("service", service.ID) 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 { if err != nil {
return err return err
} }

View file

@ -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 { if err != nil {
return err return err
} }

View file

@ -34,7 +34,7 @@ func getServices(
) ([]swarm.Service, error) { ) ([]swarm.Service, error) {
return apiclient.ServiceList( return apiclient.ServiceList(
ctx, ctx,
types.ServiceListOptions{Filter: getStackFilter(namespace)}) types.ServiceListOptions{Filters: getStackFilter(namespace)})
} }
func getNetworks( func getNetworks(

View file

@ -87,7 +87,7 @@ func getStacks(
services, err := apiclient.ServiceList( services, err := apiclient.ServiceList(
ctx, ctx,
types.ServiceListOptions{Filter: filter}) types.ServiceListOptions{Filters: filter})
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -56,7 +56,7 @@ func runPS(dockerCli *command.DockerCli, opts psOptions) error {
filter.Add("desired-state", string(swarm.TaskStateAccepted)) 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 { if err != nil {
return err return err
} }

View file

@ -46,7 +46,7 @@ func runServices(dockerCli *command.DockerCli, opts servicesOptions) error {
filter := opts.filter.Value() filter := opts.filter.Value()
filter.Add("label", labelNamespace+"="+opts.namespace) 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 { if err != nil {
return err return err
} }
@ -67,7 +67,7 @@ func runServices(dockerCli *command.DockerCli, opts servicesOptions) error {
taskFilter.Add("service", service.ID) 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 { if err != nil {
return err return err
} }

View file

@ -34,8 +34,8 @@ func (cli *Client) ContainerList(ctx context.Context, options types.ContainerLis
query.Set("size", "1") query.Set("size", "1")
} }
if options.Filter.Len() > 0 { if options.Filters.Len() > 0 {
filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filter) filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -82,10 +82,10 @@ func TestContainerList(t *testing.T) {
filters.Add("label", "label2") filters.Add("label", "label2")
filters.Add("before", "container") filters.Add("before", "container")
containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{ containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{
Size: true, Size: true,
All: true, All: true,
Since: "container", Since: "container",
Filter: filters, Filters: filters,
}) })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)

View file

@ -14,8 +14,8 @@ import (
func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
query := url.Values{} query := url.Values{}
if options.Filter.Len() > 0 { if options.Filters.Len() > 0 {
filterJSON, err := filters.ToParam(options.Filter) filterJSON, err := filters.ToParam(options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err

View file

@ -45,7 +45,7 @@ func TestNodeList(t *testing.T) {
}, },
{ {
options: types.NodeListOptions{ options: types.NodeListOptions{
Filter: filters, Filters: filters,
}, },
expectedQueryParams: map[string]string{ expectedQueryParams: map[string]string{
"filters": `{"label":{"label1":true,"label2":true}}`, "filters": `{"label":{"label1":true,"label2":true}}`,

View file

@ -14,8 +14,8 @@ import (
func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
query := url.Values{} query := url.Values{}
if options.Filter.Len() > 0 { if options.Filters.Len() > 0 {
filterJSON, err := filters.ToParam(options.Filter) filterJSON, err := filters.ToParam(options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -45,7 +45,7 @@ func TestServiceList(t *testing.T) {
}, },
{ {
options: types.ServiceListOptions{ options: types.ServiceListOptions{
Filter: filters, Filters: filters,
}, },
expectedQueryParams: map[string]string{ expectedQueryParams: map[string]string{
"filters": `{"label":{"label1":true,"label2":true}}`, "filters": `{"label":{"label1":true,"label2":true}}`,

View file

@ -14,8 +14,8 @@ import (
func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
query := url.Values{} query := url.Values{}
if options.Filter.Len() > 0 { if options.Filters.Len() > 0 {
filterJSON, err := filters.ToParam(options.Filter) filterJSON, err := filters.ToParam(options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -45,7 +45,7 @@ func TestTaskList(t *testing.T) {
}, },
{ {
options: types.TaskListOptions{ options: types.TaskListOptions{
Filter: filters, Filters: filters,
}, },
expectedQueryParams: map[string]string{ expectedQueryParams: map[string]string{
"filters": `{"label":{"label1":true,"label2":true}}`, "filters": `{"label":{"label1":true,"label2":true}}`,

View file

@ -597,7 +597,7 @@ func (c *Cluster) listContainerForNode(nodeID string) ([]string, error) {
filters := filters.NewArgs() filters := filters.NewArgs()
filters.Add("label", fmt.Sprintf("com.docker.swarm.node.id=%s", nodeID)) filters.Add("label", fmt.Sprintf("com.docker.swarm.node.id=%s", nodeID))
containers, err := c.config.Backend.Containers(&apitypes.ContainerListOptions{ containers, err := c.config.Backend.Containers(&apitypes.ContainerListOptions{
Filter: filters, Filters: filters,
}) })
if err != nil { if err != nil {
return []string{}, err return []string{}, err
@ -840,7 +840,7 @@ func (c *Cluster) GetServices(options apitypes.ServiceListOptions) ([]types.Serv
return nil, c.errNoManager() return nil, c.errNoManager()
} }
filters, err := newListServicesFilters(options.Filter) filters, err := newListServicesFilters(options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1019,7 +1019,7 @@ func (c *Cluster) GetNodes(options apitypes.NodeListOptions) ([]types.Node, erro
return nil, c.errNoManager() return nil, c.errNoManager()
} }
filters, err := newListNodesFilters(options.Filter) filters, err := newListNodesFilters(options.Filters)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1149,7 +1149,7 @@ func (c *Cluster) GetTasks(options apitypes.TaskListOptions) ([]types.Task, erro
return nil return nil
} }
filters, err := newListTasksFilters(options.Filter, byName) filters, err := newListTasksFilters(options.Filters, byName)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -217,7 +217,7 @@ func (daemon *Daemon) reducePsContainer(container *container.Container, ctx *lis
// foldFilter generates the container filter based on the user's filtering options. // foldFilter generates the container filter based on the user's filtering options.
func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listContext, error) { func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listContext, error) {
psFilters := config.Filter psFilters := config.Filters
if err := psFilters.Validate(acceptedPsFilterTags); err != nil { if err := psFilters.Validate(acceptedPsFilterTags); err != nil {
return nil, err return nil, err