Move api/client -> cli/command
Using
gomvpkg
-from github.com/docker/docker/api/client
-to github.com/docker/docker/cli/command
-vcs_mv_cmd 'git mv {{.Src}} {{.Dst}}'
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
50
command/stack/common.go
Normal file
50
command/stack/common.go
Normal file
@ -0,0 +1,50 @@
|
||||
// +build experimental
|
||||
|
||||
package stack
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/client"
|
||||
)
|
||||
|
||||
const (
|
||||
labelNamespace = "com.docker.stack.namespace"
|
||||
)
|
||||
|
||||
func getStackLabels(namespace string, labels map[string]string) map[string]string {
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
labels[labelNamespace] = namespace
|
||||
return labels
|
||||
}
|
||||
|
||||
func getStackFilter(namespace string) filters.Args {
|
||||
filter := filters.NewArgs()
|
||||
filter.Add("label", labelNamespace+"="+namespace)
|
||||
return filter
|
||||
}
|
||||
|
||||
func getServices(
|
||||
ctx context.Context,
|
||||
apiclient client.APIClient,
|
||||
namespace string,
|
||||
) ([]swarm.Service, error) {
|
||||
return apiclient.ServiceList(
|
||||
ctx,
|
||||
types.ServiceListOptions{Filter: getStackFilter(namespace)})
|
||||
}
|
||||
|
||||
func getNetworks(
|
||||
ctx context.Context,
|
||||
apiclient client.APIClient,
|
||||
namespace string,
|
||||
) ([]types.NetworkResource, error) {
|
||||
return apiclient.NetworkList(
|
||||
ctx,
|
||||
types.NetworkListOptions{Filters: getStackFilter(namespace)})
|
||||
}
|
||||
Reference in New Issue
Block a user