mirror of https://github.com/docker/cli.git
Merge pull request #1084 from thaJeztah/minor-code-refactor
Minor refactor in stack helper functions
This commit is contained in:
commit
537e67d462
|
@ -17,7 +17,7 @@ func getStackFilter(namespace string) filters.Args {
|
||||||
return filter
|
return filter
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServiceFilter(namespace string) filters.Args {
|
func getStackServiceFilter(namespace string) filters.Args {
|
||||||
return getStackFilter(namespace)
|
return getStackFilter(namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,42 +33,18 @@ func getAllStacksFilter() filters.Args {
|
||||||
return filter
|
return filter
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServices(
|
func getStackServices(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Service, error) {
|
||||||
ctx context.Context,
|
return apiclient.ServiceList(ctx, types.ServiceListOptions{Filters: getStackServiceFilter(namespace)})
|
||||||
apiclient client.APIClient,
|
|
||||||
namespace string,
|
|
||||||
) ([]swarm.Service, error) {
|
|
||||||
return apiclient.ServiceList(
|
|
||||||
ctx,
|
|
||||||
types.ServiceListOptions{Filters: getServiceFilter(namespace)})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStackNetworks(
|
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]types.NetworkResource, error) {
|
||||||
ctx context.Context,
|
return apiclient.NetworkList(ctx, types.NetworkListOptions{Filters: getStackFilter(namespace)})
|
||||||
apiclient client.APIClient,
|
|
||||||
namespace string,
|
|
||||||
) ([]types.NetworkResource, error) {
|
|
||||||
return apiclient.NetworkList(
|
|
||||||
ctx,
|
|
||||||
types.NetworkListOptions{Filters: getStackFilter(namespace)})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStackSecrets(
|
func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Secret, error) {
|
||||||
ctx context.Context,
|
return apiclient.SecretList(ctx, types.SecretListOptions{Filters: getStackFilter(namespace)})
|
||||||
apiclient client.APIClient,
|
|
||||||
namespace string,
|
|
||||||
) ([]swarm.Secret, error) {
|
|
||||||
return apiclient.SecretList(
|
|
||||||
ctx,
|
|
||||||
types.SecretListOptions{Filters: getStackFilter(namespace)})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStackConfigs(
|
func getStackConfigs(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Config, error) {
|
||||||
ctx context.Context,
|
return apiclient.ConfigList(ctx, types.ConfigListOptions{Filters: getStackFilter(namespace)})
|
||||||
apiclient client.APIClient,
|
|
||||||
namespace string,
|
|
||||||
) ([]swarm.Config, error) {
|
|
||||||
return apiclient.ConfigList(
|
|
||||||
ctx,
|
|
||||||
types.ConfigListOptions{Filters: getStackFilter(namespace)})
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ func checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error
|
||||||
func pruneServices(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, services map[string]struct{}) {
|
func pruneServices(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, services map[string]struct{}) {
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
oldServices, err := getServices(ctx, client, namespace.Name())
|
oldServices, err := getStackServices(ctx, client, namespace.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(dockerCli.Err(), "Failed to list services: %s\n", err)
|
fmt.Fprintf(dockerCli.Err(), "Failed to list services: %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ func deployServices(
|
||||||
apiClient := dockerCli.Client()
|
apiClient := dockerCli.Client()
|
||||||
out := dockerCli.Out()
|
out := dockerCli.Out()
|
||||||
|
|
||||||
existingServices, err := getServices(ctx, apiClient, namespace.Name())
|
existingServices, err := getStackServices(ctx, apiClient, namespace.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ func RunRemove(dockerCli command.Cli, opts options.Remove) error {
|
||||||
|
|
||||||
var errs []string
|
var errs []string
|
||||||
for _, namespace := range namespaces {
|
for _, namespace := range namespaces {
|
||||||
services, err := getServices(ctx, client, namespace)
|
services, err := getStackServices(ctx, client, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue