diff --git a/cli/command/image/prune.go b/cli/command/image/prune.go index 5672358e29..ea99e8482d 100644 --- a/cli/command/image/prune.go +++ b/cli/command/image/prune.go @@ -67,8 +67,7 @@ func cloneFilter(args filters.Args) (newArgs filters.Args, err error) { if err != nil { return newArgs, err } - err = newArgs.UnmarshalJSON(b) - return newArgs, err + return filters.FromJSON(string(b)) } func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) { diff --git a/cli/command/image/prune_test.go b/cli/command/image/prune_test.go index ca46bbf6bb..884a485471 100644 --- a/cli/command/image/prune_test.go +++ b/cli/command/image/prune_test.go @@ -70,6 +70,14 @@ func TestNewPruneCommandSuccess(t *testing.T) { }, nil }, }, + { + name: "label-filter", + args: []string{"--force", "--filter", "label=foobar"}, + imagesPruneFunc: func(pruneFilter filters.Args) (types.ImagesPruneReport, error) { + assert.Check(t, is.Equal("foobar", pruneFilter.Get("label")[0])) + return types.ImagesPruneReport{}, nil + }, + }, { name: "force-untagged", args: []string{"--force"}, diff --git a/cli/command/image/testdata/prune-command-success.label-filter.golden b/cli/command/image/testdata/prune-command-success.label-filter.golden new file mode 100644 index 0000000000..6c537e1ac2 --- /dev/null +++ b/cli/command/image/testdata/prune-command-success.label-filter.golden @@ -0,0 +1 @@ +Total reclaimed space: 0B