docker: github.com/docker/docker/api/types/filters Index | Files

package filters

import "github.com/docker/docker/api/types/filters"

Package filters provides helper function to parse and handle command line filter, used for example in docker ps or docker images commands.

Index

Package Files

parse.go

Variables

var ErrBadFormat = errors.New("bad format of filter (expected name=value)")

ErrBadFormat is an error returned in case of bad format for a filter.

func ToParam Uses

func ToParam(a Args) (string, error)

ToParam packs the Args into a string for easy transport from client to server.

func ToParamWithVersion Uses

func ToParamWithVersion(version string, a Args) (string, error)

ToParamWithVersion packs the Args into a string for easy transport from client to server. The generated string will depend on the specified version (corresponding to the API version).

type Args Uses

type Args struct {
    // contains filtered or unexported fields
}

Args stores filter arguments as map key:{map key: bool}. It contains an aggregation of the map of arguments (which are in the form of -f 'key=value') based on the key, and stores values for the same key in a map with string keys and boolean values. e.g given -f 'label=label1=1' -f 'label=label2=2' -f 'image.name=ubuntu' the args will be {"image.name":{"ubuntu":true},"label":{"label1=1":true,"label2=2":true}}

func FromParam Uses

func FromParam(p string) (Args, error)

FromParam unpacks the filter Args.

func NewArgs Uses

func NewArgs() Args

NewArgs initializes a new Args struct.

func ParseFlag Uses

func ParseFlag(arg string, prev Args) (Args, error)

ParseFlag parses the argument to the filter flag. Like

`docker ps -f 'created=today' -f 'image.name=ubuntu*'`

If prev map is provided, then it is appended to, and returned. By default a new map is created.

func (Args) Add Uses

func (filters Args) Add(name, value string)

Add adds a new value to a filter field.

func (Args) Del Uses

func (filters Args) Del(name, value string)

Del removes a value from a filter field.

func (Args) ExactMatch Uses

func (filters Args) ExactMatch(field, source string) bool

ExactMatch returns true if the source matches exactly one of the filters.

func (Args) FuzzyMatch Uses

func (filters Args) FuzzyMatch(field, source string) bool

FuzzyMatch returns true if the source matches exactly one of the filters, or the source has one of the filters as a prefix.

func (Args) Get Uses

func (filters Args) Get(field string) []string

Get returns the list of values associates with a field. It returns a slice of strings to keep backwards compatibility with old code.

func (Args) Include Uses

func (filters Args) Include(field string) bool

Include returns true if the name of the field to filter is in the filters.

func (Args) Len Uses

func (filters Args) Len() int

Len returns the number of fields in the arguments.

func (Args) Match Uses

func (filters Args) Match(field, source string) bool

Match returns true if the values for the specified field matches the source string e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}},

field is 'image.name' and source is 'ubuntu'
it returns true.

func (Args) MatchKVList Uses

func (filters Args) MatchKVList(field string, sources map[string]string) bool

MatchKVList returns true if the values for the specified field matches the ones from the sources. e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}},

field is 'label' and sources are {'label1': '1', 'label2': '2'}
it returns true.

func (Args) UniqueExactMatch Uses

func (filters Args) UniqueExactMatch(field, source string) bool

UniqueExactMatch returns true if there is only one filter and the source matches exactly this one.

func (Args) Validate Uses

func (filters Args) Validate(accepted map[string]bool) error

Validate ensures that all the fields in the filter are valid. It returns an error as soon as it finds an invalid field.

func (Args) WalkValues Uses

func (filters Args) WalkValues(field string, op func(value string) error) error

WalkValues iterates over the list of filtered values for a field. It stops the iteration if it finds an error and it returns that error.

Package filters imports 6 packages (graph) and is imported by 634 packages. Updated 2017-02-27. Refresh now. Tools for package owners.