|
@@ -5,7 +5,6 @@ package filters // import "github.com/docker/docker/api/types/filters"
|
|
|
|
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
- "errors"
|
|
|
|
"regexp"
|
|
"regexp"
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
@@ -37,41 +36,6 @@ func NewArgs(initialArgs ...KeyValuePair) Args {
|
|
return args
|
|
return args
|
|
}
|
|
}
|
|
|
|
|
|
-// ParseFlag parses a key=value string and adds it to an Args.
|
|
|
|
-//
|
|
|
|
-// Deprecated: Use Args.Add()
|
|
|
|
-func ParseFlag(arg string, prev Args) (Args, error) {
|
|
|
|
- filters := prev
|
|
|
|
- if len(arg) == 0 {
|
|
|
|
- return filters, nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if !strings.Contains(arg, "=") {
|
|
|
|
- return filters, ErrBadFormat
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- f := strings.SplitN(arg, "=", 2)
|
|
|
|
-
|
|
|
|
- name := strings.ToLower(strings.TrimSpace(f[0]))
|
|
|
|
- value := strings.TrimSpace(f[1])
|
|
|
|
-
|
|
|
|
- filters.Add(name, value)
|
|
|
|
-
|
|
|
|
- return filters, nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// ErrBadFormat is an error returned when a filter is not in the form key=value
|
|
|
|
-//
|
|
|
|
-// Deprecated: this error will be removed in a future version
|
|
|
|
-var ErrBadFormat = errors.New("bad format of filter (expected name=value)")
|
|
|
|
-
|
|
|
|
-// ToParam encodes the Args as args JSON encoded string
|
|
|
|
-//
|
|
|
|
-// Deprecated: use ToJSON
|
|
|
|
-func ToParam(a Args) (string, error) {
|
|
|
|
- return ToJSON(a)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// MarshalJSON returns a JSON byte representation of the Args
|
|
// MarshalJSON returns a JSON byte representation of the Args
|
|
func (args Args) MarshalJSON() ([]byte, error) {
|
|
func (args Args) MarshalJSON() ([]byte, error) {
|
|
if len(args.fields) == 0 {
|
|
if len(args.fields) == 0 {
|
|
@@ -107,13 +71,6 @@ func ToParamWithVersion(version string, a Args) (string, error) {
|
|
return ToJSON(a)
|
|
return ToJSON(a)
|
|
}
|
|
}
|
|
|
|
|
|
-// FromParam decodes a JSON encoded string into Args
|
|
|
|
-//
|
|
|
|
-// Deprecated: use FromJSON
|
|
|
|
-func FromParam(p string) (Args, error) {
|
|
|
|
- return FromJSON(p)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// FromJSON decodes a JSON encoded string into Args
|
|
// FromJSON decodes a JSON encoded string into Args
|
|
func FromJSON(p string) (Args, error) {
|
|
func FromJSON(p string) (Args, error) {
|
|
args := NewArgs()
|
|
args := NewArgs()
|
|
@@ -275,14 +232,6 @@ func (args Args) FuzzyMatch(key, source string) bool {
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
|
|
-// Include returns true if the key exists in the mapping
|
|
|
|
-//
|
|
|
|
-// Deprecated: use Contains
|
|
|
|
-func (args Args) Include(field string) bool {
|
|
|
|
- _, ok := args.fields[field]
|
|
|
|
- return ok
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Contains returns true if the key exists in the mapping
|
|
// Contains returns true if the key exists in the mapping
|
|
func (args Args) Contains(field string) bool {
|
|
func (args Args) Contains(field string) bool {
|
|
_, ok := args.fields[field]
|
|
_, ok := args.fields[field]
|