本文整理汇总了Golang中github.com/docker/engine-api/types/filters.Args类的典型用法代码示例。如果您正苦于以下问题:Golang Args类的具体用法?Golang Args怎么用?Golang Args使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Args类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: FilterNetworks
// FilterNetworks returns a list of networks filtered by the given arguments.
// It returns an error if the filters are not included in the list of accepted filters.
func (daemon *Daemon) FilterNetworks(netFilters filters.Args) ([]libnetwork.Network, error) {
if netFilters.Len() != 0 {
if err := netFilters.Validate(netsettings.AcceptedFilters); err != nil {
return nil, err
}
}
nwList := daemon.getAllNetworks()
return netsettings.FilterNetworks(nwList, netFilters)
}
开发者ID:joshal,项目名称:docker,代码行数:11,代码来源:network.go
示例2: VolumeList
// VolumeList returns the volumes configured in the docker host.
func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) {
var volumes types.VolumesListResponse
query := url.Values{}
if filter.Len() > 0 {
filterJSON, err := filters.ToParam(filter)
if err != nil {
return volumes, err
}
query.Set("filters", filterJSON)
}
resp, err := cli.get(ctx, "/volumes", query, nil)
if err != nil {
return volumes, err
}
err = json.NewDecoder(resp.body).Decode(&volumes)
ensureReaderClosed(resp)
return volumes, err
}
开发者ID:Clarifai,项目名称:kubernetes,代码行数:21,代码来源:volume_list.go
示例3: FilterNetworks
// FilterNetworks filters network list according to user specified filter
// and returns user chosen networks
func FilterNetworks(nws []libnetwork.Network, filter filters.Args) ([]libnetwork.Network, error) {
// if filter is empty, return original network list
if filter.Len() == 0 {
return nws, nil
}
var displayNet []libnetwork.Network
for fkey, fhandler := range supportedFilters {
errFilter := filter.WalkValues(fkey, func(fval string) error {
passList, err := fhandler(nws, fval)
if err != nil {
return err
}
displayNet = append(displayNet, passList...)
return nil
})
if errFilter != nil {
return nil, errFilter
}
}
return displayNet, nil
}
开发者ID:ungureanuvladvictor,项目名称:docker,代码行数:24,代码来源:filter.go
示例4: newListServicesFilters
func newListServicesFilters(filter filters.Args) (*swarmapi.ListServicesRequest_Filters, error) {
accepted := map[string]bool{
"name": true,
"id": true,
"label": true,
}
if err := filter.Validate(accepted); err != nil {
return nil, err
}
return &swarmapi.ListServicesRequest_Filters{
Names: filter.Get("name"),
IDPrefixes: filter.Get("id"),
Labels: runconfigopts.ConvertKVStringsToMap(filter.Get("label")),
}, nil
}
开发者ID:FlyingShit-XinHuang,项目名称:docker,代码行数:15,代码来源:filters.go
示例5: newListTasksFilters
func newListTasksFilters(filter filters.Args) (*swarmapi.ListTasksRequest_Filters, error) {
accepted := map[string]bool{
"name": true,
"id": true,
"label": true,
"service": true,
"node": true,
"desired_state": true,
}
if err := filter.Validate(accepted); err != nil {
return nil, err
}
f := &swarmapi.ListTasksRequest_Filters{
Names: filter.Get("name"),
IDPrefixes: filter.Get("id"),
Labels: runconfigopts.ConvertKVStringsToMap(filter.Get("label")),
ServiceIDs: filter.Get("service"),
NodeIDs: filter.Get("node"),
}
for _, s := range filter.Get("desired_state") {
if state, ok := swarmapi.TaskState_value[strings.ToUpper(s)]; ok {
f.DesiredStates = append(f.DesiredStates, swarmapi.TaskState(state))
} else if s != "" {
return nil, fmt.Errorf("Invalid desired_state filter: '%s'", s)
}
}
return f, nil
}
开发者ID:FlyingShit-XinHuang,项目名称:docker,代码行数:30,代码来源:filters.go
示例6: newListNodesFilters
func newListNodesFilters(filter filters.Args) (*swarmapi.ListNodesRequest_Filters, error) {
accepted := map[string]bool{
"name": true,
"id": true,
"label": true,
"role": true,
"membership": true,
}
if err := filter.Validate(accepted); err != nil {
return nil, err
}
f := &swarmapi.ListNodesRequest_Filters{
Names: filter.Get("name"),
IDPrefixes: filter.Get("id"),
Labels: runconfigopts.ConvertKVStringsToMap(filter.Get("label")),
}
for _, r := range filter.Get("role") {
if role, ok := swarmapi.NodeRole_value[strings.ToUpper(r)]; ok {
f.Roles = append(f.Roles, swarmapi.NodeRole(role))
} else if r != "" {
return nil, fmt.Errorf("Invalid role filter: '%s'", r)
}
}
for _, a := range filter.Get("membership") {
if membership, ok := swarmapi.NodeSpec_Membership_value[strings.ToUpper(a)]; ok {
f.Memberships = append(f.Memberships, swarmapi.NodeSpec_Membership(membership))
} else if a != "" {
return nil, fmt.Errorf("Invalid membership filter: '%s'", a)
}
}
return f, nil
}
开发者ID:FlyingShit-XinHuang,项目名称:docker,代码行数:35,代码来源:filters.go
示例7: filterVolumes
// filterVolumes filters volume list according to user specified filter
// and returns user chosen volumes
func (daemon *Daemon) filterVolumes(vols []volume.Volume, filter filters.Args) ([]volume.Volume, error) {
// if filter is empty, return original volume list
if filter.Len() == 0 {
return vols, nil
}
var retVols []volume.Volume
for _, vol := range vols {
if filter.Include("name") {
if !filter.Match("name", vol.Name()) {
continue
}
}
if filter.Include("driver") {
if !filter.Match("driver", vol.DriverName()) {
continue
}
}
retVols = append(retVols, vol)
}
danglingOnly := false
if filter.Include("dangling") {
if filter.ExactMatch("dangling", "true") || filter.ExactMatch("dangling", "1") {
danglingOnly = true
} else if !filter.ExactMatch("dangling", "false") && !filter.ExactMatch("dangling", "0") {
return nil, fmt.Errorf("Invalid filter 'dangling=%s'", filter.Get("dangling"))
}
retVols = daemon.volumes.FilterByUsed(retVols, !danglingOnly)
}
return retVols, nil
}
开发者ID:RAMESHBABUK,项目名称:docker,代码行数:33,代码来源:list.go
示例8: FilterNetworks
// FilterNetworks filters network list according to user specified filter
// and returns user chosen networks
func FilterNetworks(nws []libnetwork.Network, filter filters.Args) ([]libnetwork.Network, error) {
// if filter is empty, return original network list
if filter.Len() == 0 {
return nws, nil
}
var displayNet []libnetwork.Network
for _, nw := range nws {
if filter.Include("driver") {
if !filter.ExactMatch("driver", nw.Type()) {
continue
}
}
if filter.Include("name") {
if !filter.Match("name", nw.Name()) {
continue
}
}
if filter.Include("id") {
if !filter.Match("id", nw.ID()) {
continue
}
}
if filter.Include("label") {
if !filter.MatchKVList("label", nw.Info().Labels()) {
continue
}
}
displayNet = append(displayNet, nw)
}
if filter.Include("type") {
var typeNet []libnetwork.Network
errFilter := filter.WalkValues("type", func(fval string) error {
passList, err := filterNetworkByType(displayNet, fval)
if err != nil {
return err
}
typeNet = append(typeNet, passList...)
return nil
})
if errFilter != nil {
return nil, errFilter
}
displayNet = typeNet
}
return displayNet, nil
}
开发者ID:Cybertinus,项目名称:docker,代码行数:51,代码来源:filter.go
示例9: filterNetworks
// filterNetworks filters network list according to user specified filter
// and returns user chosen networks
func filterNetworks(nws []types.NetworkResource, filter filters.Args) ([]types.NetworkResource, error) {
// if filter is empty, return original network list
if filter.Len() == 0 {
return nws, nil
}
if err := filter.Validate(AcceptedFilters); err != nil {
return nil, err
}
var displayNet []types.NetworkResource
for _, nw := range nws {
if filter.Include("driver") {
if !filter.ExactMatch("driver", nw.Driver) {
continue
}
}
if filter.Include("name") {
if !filter.Match("name", nw.Name) {
continue
}
}
if filter.Include("id") {
if !filter.Match("id", nw.ID) {
continue
}
}
if filter.Include("label") {
if !filter.MatchKVList("label", nw.Labels) {
continue
}
}
displayNet = append(displayNet, nw)
}
if filter.Include("type") {
var typeNet []types.NetworkResource
errFilter := filter.WalkValues("type", func(fval string) error {
passList, err := filterNetworkByType(displayNet, fval)
if err != nil {
return err
}
typeNet = append(typeNet, passList...)
return nil
})
if errFilter != nil {
return nil, errFilter
}
displayNet = typeNet
}
return displayNet, nil
}
开发者ID:CheggEng,项目名称:docker,代码行数:55,代码来源:filter.go
注:本文中的github.com/docker/engine-api/types/filters.Args类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论