mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
filters: add Clone() method
Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
68cbc3712c
commit
59eacf28d6
2 changed files with 24 additions and 0 deletions
|
@ -323,6 +323,22 @@ func (args Args) WalkValues(field string, op func(value string) error) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone returns a copy of args.
|
||||||
|
func (args Args) Clone() (newArgs Args) {
|
||||||
|
newArgs.fields = make(map[string]map[string]bool, len(args.fields))
|
||||||
|
for k, m := range args.fields {
|
||||||
|
var mm map[string]bool
|
||||||
|
if m != nil {
|
||||||
|
mm = make(map[string]bool, len(m))
|
||||||
|
for kk, v := range m {
|
||||||
|
mm[kk] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newArgs.fields[k] = mm
|
||||||
|
}
|
||||||
|
return newArgs
|
||||||
|
}
|
||||||
|
|
||||||
func deprecatedArgs(d map[string][]string) map[string]map[string]bool {
|
func deprecatedArgs(d map[string][]string) map[string]map[string]bool {
|
||||||
m := map[string]map[string]bool{}
|
m := map[string]map[string]bool{}
|
||||||
for k, v := range d {
|
for k, v := range d {
|
||||||
|
|
|
@ -421,3 +421,11 @@ func TestFuzzyMatch(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClone(t *testing.T) {
|
||||||
|
f := NewArgs()
|
||||||
|
f.Add("foo", "bar")
|
||||||
|
f2 := f.Clone()
|
||||||
|
f2.Add("baz", "qux")
|
||||||
|
assert.Check(t, is.Len(f.Get("baz"), 0))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue