mirror of https://github.com/docker/cli.git
cli/command: use strings.Cut
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
acc45f5494
commit
cb19bf9f7d
|
@ -96,26 +96,26 @@ func PruneFilters(dockerCli Cli, pruneFilters filters.Args) filters.Args {
|
||||||
return pruneFilters
|
return pruneFilters
|
||||||
}
|
}
|
||||||
for _, f := range dockerCli.ConfigFile().PruneFilters {
|
for _, f := range dockerCli.ConfigFile().PruneFilters {
|
||||||
parts := strings.SplitN(f, "=", 2)
|
k, v, ok := strings.Cut(f, "=")
|
||||||
if len(parts) != 2 {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if parts[0] == "label" {
|
if k == "label" {
|
||||||
// CLI label filter supersede config.json.
|
// CLI label filter supersede config.json.
|
||||||
// If CLI label filter conflict with config.json,
|
// If CLI label filter conflict with config.json,
|
||||||
// skip adding label! filter in config.json.
|
// skip adding label! filter in config.json.
|
||||||
if pruneFilters.Contains("label!") && pruneFilters.ExactMatch("label!", parts[1]) {
|
if pruneFilters.Contains("label!") && pruneFilters.ExactMatch("label!", v) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if parts[0] == "label!" {
|
} else if k == "label!" {
|
||||||
// CLI label! filter supersede config.json.
|
// CLI label! filter supersede config.json.
|
||||||
// If CLI label! filter conflict with config.json,
|
// If CLI label! filter conflict with config.json,
|
||||||
// skip adding label filter in config.json.
|
// skip adding label filter in config.json.
|
||||||
if pruneFilters.Contains("label") && pruneFilters.ExactMatch("label", parts[1]) {
|
if pruneFilters.Contains("label") && pruneFilters.ExactMatch("label", v) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pruneFilters.Add(parts[0], parts[1])
|
pruneFilters.Add(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pruneFilters
|
return pruneFilters
|
||||||
|
|
Loading…
Reference in New Issue