From 406799eb1c32242fd8283b7b6684392d47e4d4ba Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 5 Aug 2022 17:20:52 +0100 Subject: [PATCH] prune: cleanup variable names for clarity Signed-off-by: Justin Chadwell --- commands/prune.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/commands/prune.go b/commands/prune.go index 4040b8b3..9011d66d 100644 --- a/commands/prune.go +++ b/commands/prune.go @@ -155,9 +155,9 @@ func toBuildkitPruneInfo(f filters.Args) (*client.PruneInfo, error) { if len(untilValues) > 0 && len(unusedForValues) > 0 { return nil, errors.Errorf("conflicting filters %q and %q", "until", "unused-for") } - filterKey := "until" + untilKey := "until" if len(unusedForValues) > 0 { - filterKey = "unused-for" + untilKey = "unused-for" } untilValues = append(untilValues, unusedForValues...) @@ -168,27 +168,27 @@ func toBuildkitPruneInfo(f filters.Args) (*client.PruneInfo, error) { var err error until, err = time.ParseDuration(untilValues[0]) if err != nil { - return nil, errors.Wrapf(err, "%q filter expects a duration (e.g., '24h')", filterKey) + return nil, errors.Wrapf(err, "%q filter expects a duration (e.g., '24h')", untilKey) } default: return nil, errors.Errorf("filters expect only one value") } - bkFilter := make([]string, 0, f.Len()) - for _, field := range f.Keys() { - if field == filterKey { + filters := make([]string, 0, f.Len()) + for _, filterKey := range f.Keys() { + if filterKey == untilKey { continue } - values := f.Get(field) + values := f.Get(filterKey) switch len(values) { case 0: - bkFilter = append(bkFilter, field) + filters = append(filters, filterKey) case 1: - if field == "id" { - bkFilter = append(bkFilter, field+"~="+values[0]) + if filterKey == "id" { + filters = append(filters, filterKey+"~="+values[0]) } else { - bkFilter = append(bkFilter, field+"=="+values[0]) + filters = append(filters, filterKey+"=="+values[0]) } default: return nil, errors.Errorf("filters expect only one value") @@ -196,6 +196,6 @@ func toBuildkitPruneInfo(f filters.Args) (*client.PruneInfo, error) { } return &client.PruneInfo{ KeepDuration: until, - Filter: []string{strings.Join(bkFilter, ",")}, + Filter: []string{strings.Join(filters, ",")}, }, nil }