mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Set labels on container create
Signed-off-by: Darren Shepherd <darren@rancher.com>
This commit is contained in:
parent
cdfdfbfb62
commit
abb5e9a077
8 changed files with 264 additions and 11 deletions
|
|
@ -65,6 +65,38 @@ func FromParam(p string) (Args, error) {
|
|||
return args, nil
|
||||
}
|
||||
|
||||
func (filters Args) MatchKVList(field string, sources map[string]string) bool {
|
||||
fieldValues := filters[field]
|
||||
|
||||
//do not filter if there is no filter set or cannot determine filter
|
||||
if len(fieldValues) == 0 {
|
||||
return true
|
||||
}
|
||||
|
||||
if sources == nil || len(sources) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
outer:
|
||||
for _, name2match := range fieldValues {
|
||||
testKV := strings.SplitN(name2match, "=", 2)
|
||||
|
||||
for k, v := range sources {
|
||||
if len(testKV) == 1 {
|
||||
if k == testKV[0] {
|
||||
continue outer
|
||||
}
|
||||
} else if k == testKV[0] && v == testKV[1] {
|
||||
continue outer
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (filters Args) Match(field, source string) bool {
|
||||
fieldValues := filters[field]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue