Merge pull request #30740 from yongtang/29999-prune-filter-label

Add `label` filter for `docker system prune`
This commit is contained in:
Vincent Demeester 2017-04-10 19:38:01 +02:00 committed by GitHub
commit 3ac3a56f1c
3 changed files with 39 additions and 0 deletions

View File

@ -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{

View File

@ -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{

View File

@ -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{