mirror of https://github.com/docker/cli.git
Merge pull request #30740 from yongtang/29999-prune-filter-label
Add `label` filter for `docker system prune`
This commit is contained in:
commit
3ac3a56f1c
|
@ -40,6 +40,11 @@ func TestContainersPrune(t *testing.T) {
|
|||
danglingUntilFilters.Add("dangling", "true")
|
||||
danglingUntilFilters.Add("until", "2016-12-15T14:00")
|
||||
|
||||
labelFilters := filters.NewArgs()
|
||||
labelFilters.Add("dangling", "true")
|
||||
labelFilters.Add("label", "label1=foo")
|
||||
labelFilters.Add("label", "label2!=bar")
|
||||
|
||||
listCases := []struct {
|
||||
filters filters.Args
|
||||
expectedQueryParams map[string]string
|
||||
|
@ -76,6 +81,14 @@ func TestContainersPrune(t *testing.T) {
|
|||
"filters": `{"dangling":{"false":true}}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
filters: labelFilters,
|
||||
expectedQueryParams: map[string]string{
|
||||
"until": "",
|
||||
"filter": "",
|
||||
"filters": `{"dangling":{"true":true},"label":{"label1=foo":true,"label2!=bar":true}}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, listCase := range listCases {
|
||||
client := &Client{
|
||||
|
|
|
@ -36,6 +36,11 @@ func TestImagesPrune(t *testing.T) {
|
|||
noDanglingFilters := filters.NewArgs()
|
||||
noDanglingFilters.Add("dangling", "false")
|
||||
|
||||
labelFilters := filters.NewArgs()
|
||||
labelFilters.Add("dangling", "true")
|
||||
labelFilters.Add("label", "label1=foo")
|
||||
labelFilters.Add("label", "label2!=bar")
|
||||
|
||||
listCases := []struct {
|
||||
filters filters.Args
|
||||
expectedQueryParams map[string]string
|
||||
|
@ -64,6 +69,14 @@ func TestImagesPrune(t *testing.T) {
|
|||
"filters": `{"dangling":{"false":true}}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
filters: labelFilters,
|
||||
expectedQueryParams: map[string]string{
|
||||
"until": "",
|
||||
"filter": "",
|
||||
"filters": `{"dangling":{"true":true},"label":{"label1=foo":true,"label2!=bar":true}}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, listCase := range listCases {
|
||||
client := &Client{
|
||||
|
|
|
@ -38,6 +38,11 @@ func TestNetworksPrune(t *testing.T) {
|
|||
noDanglingFilters := filters.NewArgs()
|
||||
noDanglingFilters.Add("dangling", "false")
|
||||
|
||||
labelFilters := filters.NewArgs()
|
||||
labelFilters.Add("dangling", "true")
|
||||
labelFilters.Add("label", "label1=foo")
|
||||
labelFilters.Add("label", "label2!=bar")
|
||||
|
||||
listCases := []struct {
|
||||
filters filters.Args
|
||||
expectedQueryParams map[string]string
|
||||
|
@ -66,6 +71,14 @@ func TestNetworksPrune(t *testing.T) {
|
|||
"filters": `{"dangling":{"false":true}}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
filters: labelFilters,
|
||||
expectedQueryParams: map[string]string{
|
||||
"until": "",
|
||||
"filter": "",
|
||||
"filters": `{"dangling":{"true":true},"label":{"label1=foo":true,"label2!=bar":true}}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, listCase := range listCases {
|
||||
client := &Client{
|
||||
|
|
Loading…
Reference in New Issue