Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cli/command/system/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,14 @@ func confirmationMessage(dockerCli command.Cli, options pruneOptions) string {
if pruneFilters.Len() > 0 {
// TODO remove fixed list of filters, and print all filters instead,
// because the list of filters that is supported by the engine may evolve over time.

for _, name := range []string{"label", "label!", "until"} {
for _, v := range pruneFilters.Get(name) {
filters = append(filters, name+"="+v)
for v, isEqualOp := range options.filter.Value().GetPair(name) {
op := "="
if !isEqualOp {
op = "!="
}
filters = append(filters, name+op+v)
}
}
sort.Slice(filters, func(i, j int) bool {
Expand Down
18 changes: 14 additions & 4 deletions opts/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,25 @@ func (o *FilterOpt) Set(value string) error {
if value == "" {
return nil
}
if !strings.Contains(value, "=") {
return errors.New("bad format of filter (expected name=value)")

var isEqualOp bool
// isEqualOp determines the comparison type:
// true => use ="
// false => use "!="
var sep string
if strings.Contains(value, "!=") {
isEqualOp, sep = false, "!="
} else if strings.Contains(value, "=") {
isEqualOp, sep = true, "="
} else {
return errors.New("bad format of filter (expected name=value or name!=value)")
}
name, val, _ := strings.Cut(value, "=")
name, val, _ := strings.Cut(value, sep)

// TODO(thaJeztah): these options should not be case-insensitive.
name = strings.ToLower(strings.TrimSpace(name))
val = strings.TrimSpace(val)
o.filter.Add(name, val)
o.filter.Add(name, val, isEqualOp)
return nil
}

Expand Down
17 changes: 14 additions & 3 deletions vendor/github.com/docker/docker/api/types/filters/parse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading