mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
make network filter more flexible
Signed-off-by: JieJhih Jhang <aawer12345tw@yahoo.com.tw>
This commit is contained in:
@@ -3,6 +3,7 @@ package cluster // import "github.com/docker/docker/daemon/cluster"
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
apitypes "github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
@@ -25,8 +26,16 @@ func (c *Cluster) GetNetworks(filter filters.Args) ([]apitypes.NetworkResource,
|
||||
f = &swarmapi.ListNetworksRequest_Filters{}
|
||||
|
||||
if filter.Contains("name") {
|
||||
f.Names = filter.Get("name")
|
||||
f.NamePrefixes = filter.Get("name")
|
||||
fullName := filter.Get("name")
|
||||
|
||||
for _, v := range fullName {
|
||||
if strings.Contains(v, "*") {
|
||||
f.NamePrefixes = append(f.NamePrefixes, strings.Split(v, "*")[0])
|
||||
} else {
|
||||
f.Names = append(f.Names, v)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if filter.Contains("id") {
|
||||
|
||||
Reference in New Issue
Block a user