From 732d8b51a84d0a90ba9f440106ec177281b9009d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 20 May 2020 14:13:14 +0200 Subject: [PATCH] un-wrap some code The wrapping made the code harder to read (and in some cases destracted from the actual code flow). Some of these functions take too many arguments; instead of hiding that, it probably better to make it apparent that something needs to be done (and fix it :-)). Signed-off-by: Sebastiaan van Stijn --- cli/command/stack/swarm/deploy_composefile.go | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/cli/command/stack/swarm/deploy_composefile.go b/cli/command/stack/swarm/deploy_composefile.go index 125b35e285..2ab9be8a4f 100644 --- a/cli/command/stack/swarm/deploy_composefile.go +++ b/cli/command/stack/swarm/deploy_composefile.go @@ -77,11 +77,7 @@ func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) ma return serviceNetworks } -func validateExternalNetworks( - ctx context.Context, - client dockerclient.NetworkAPIClient, - externalNetworks []string, -) error { +func validateExternalNetworks(ctx context.Context, client dockerclient.NetworkAPIClient, externalNetworks []string) error { for _, networkName := range externalNetworks { if !container.NetworkMode(networkName).IsUserDefined() { // Networks that are not user defined always exist on all nodes as @@ -101,11 +97,7 @@ func validateExternalNetworks( return nil } -func createSecrets( - ctx context.Context, - dockerCli command.Cli, - secrets []swarm.SecretSpec, -) error { +func createSecrets(ctx context.Context, dockerCli command.Cli, secrets []swarm.SecretSpec) error { client := dockerCli.Client() for _, secretSpec := range secrets { @@ -129,11 +121,7 @@ func createSecrets( return nil } -func createConfigs( - ctx context.Context, - dockerCli command.Cli, - configs []swarm.ConfigSpec, -) error { +func createConfigs(ctx context.Context, dockerCli command.Cli, configs []swarm.ConfigSpec) error { client := dockerCli.Client() for _, configSpec := range configs { @@ -157,12 +145,7 @@ func createConfigs( return nil } -func createNetworks( - ctx context.Context, - dockerCli command.Cli, - namespace convert.Namespace, - networks map[string]types.NetworkCreate, -) error { +func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]types.NetworkCreate) error { client := dockerCli.Client() existingNetworks, err := getStackNetworks(ctx, client, namespace.Name()) @@ -193,14 +176,7 @@ func createNetworks( } // nolint: gocyclo -func deployServices( - ctx context.Context, - dockerCli command.Cli, - services map[string]swarm.ServiceSpec, - namespace convert.Namespace, - sendAuth bool, - resolveImage string, -) error { +func deployServices(ctx context.Context, dockerCli command.Cli, services map[string]swarm.ServiceSpec, namespace convert.Namespace, sendAuth bool, resolveImage string) error { apiClient := dockerCli.Client() out := dockerCli.Out() @@ -264,13 +240,7 @@ func deployServices( // TODO move this to API client? serviceSpec.TaskTemplate.ForceUpdate = service.Spec.TaskTemplate.ForceUpdate - response, err := apiClient.ServiceUpdate( - ctx, - service.ID, - service.Version, - serviceSpec, - updateOpts, - ) + response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, serviceSpec, updateOpts) if err != nil { return errors.Wrapf(err, "failed to update service %s", name) }