MCPcopy Index your code
hub / github.com/docker/cli / PruneFilters

Function PruneFilters

cli/command/utils.go:25–59  ·  view source on GitHub ↗

PruneFilters merges prune filters specified in config.json with those specified as command-line flags. It returns a deep copy of filters to prevent mutating the original. CLI label filters have precedence over those specified in config.json. If a label filter specified as flag conflicts with a labe

(dockerCLI config.Provider, filters client.Filters)

Source from the content-addressed store, hash-verified

23// (i.e., "label=some-value" conflicts with "label!=some-value", and vice versa),
24// then the filter defined in config.json is omitted.
25func PruneFilters(dockerCLI config.Provider, filters client.Filters) client.Filters {
26 pruneFilters := filters.Clone()
27
28 cfg := dockerCLI.ConfigFile()
29 if cfg == nil {
30 return pruneFilters
31 }
32
33 // Merge filters provided through the CLI with default filters defined
34 // in the CLI-configfile.
35 for _, f := range cfg.PruneFilters {
36 k, v, ok := strings.Cut(f, "=")
37 if !ok {
38 continue
39 }
40 switch k {
41 case "label":
42 // "label != some-value" conflicts with "label = some-value"
43 if pruneFilters["label!"][v] {
44 continue
45 }
46 pruneFilters.Add(k, v)
47 case "label!":
48 // "label != some-value" conflicts with "label = some-value"
49 if pruneFilters["label"][v] {
50 continue
51 }
52 pruneFilters.Add(k, v)
53 default:
54 pruneFilters.Add(k, v)
55 }
56 }
57
58 return pruneFilters
59}
60
61// ValidateOutputPath validates the output paths of the "docker cp" command.
62func ValidateOutputPath(path string) error {

Callers

nothing calls this directly

Calls 1

ConfigFileMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…