Replace uses of filters.Include() with filters.Contains()
The `filters.Include()` method was deprecated in favor of `filters.Contains()` in 065118390a3ecaf0dbd2fa752d54d43f8f1e8ec6, but still used in various locations. This patch replaces uses of `filters.Include()` with `filters.Contains()`. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 97c5ae25c4d857563acd1f3467afc760145b1d55 Component: engine
This commit is contained in:
@@ -45,27 +45,27 @@ func filterNetworks(nws []types.NetworkResource, filter filters.Args) ([]types.N
|
||||
|
||||
displayNet := []types.NetworkResource{}
|
||||
for _, nw := range nws {
|
||||
if filter.Include("driver") {
|
||||
if filter.Contains("driver") {
|
||||
if !filter.ExactMatch("driver", nw.Driver) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if filter.Include("name") {
|
||||
if filter.Contains("name") {
|
||||
if !filter.Match("name", nw.Name) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if filter.Include("id") {
|
||||
if filter.Contains("id") {
|
||||
if !filter.Match("id", nw.ID) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if filter.Include("label") {
|
||||
if filter.Contains("label") {
|
||||
if !filter.MatchKVList("label", nw.Labels) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if filter.Include("scope") {
|
||||
if filter.Contains("scope") {
|
||||
if !filter.ExactMatch("scope", nw.Scope) {
|
||||
continue
|
||||
}
|
||||
@@ -73,7 +73,7 @@ func filterNetworks(nws []types.NetworkResource, filter filters.Args) ([]types.N
|
||||
displayNet = append(displayNet, nw)
|
||||
}
|
||||
|
||||
if filter.Include("type") {
|
||||
if filter.Contains("type") {
|
||||
typeNet := []types.NetworkResource{}
|
||||
errFilter := filter.WalkValues("type", func(fval string) error {
|
||||
passList, err := filterNetworkByType(displayNet, fval)
|
||||
|
||||
@@ -337,6 +337,17 @@ func TestOnlyOneExactMatch(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestContains(t *testing.T) {
|
||||
f := NewArgs()
|
||||
if f.Contains("status") {
|
||||
t.Fatal("Expected to not contain a status key, got true")
|
||||
}
|
||||
f.Add("status", "running")
|
||||
if !f.Contains("status") {
|
||||
t.Fatal("Expected to contain a status key, got false")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInclude(t *testing.T) {
|
||||
f := NewArgs()
|
||||
if f.Include("status") {
|
||||
|
||||
Reference in New Issue
Block a user