mirror of https://github.com/docker/cli.git
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 <github@gone.nl>
This commit is contained in:
parent
47fce8f4bc
commit
732d8b51a8
|
@ -77,11 +77,7 @@ func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) ma
|
||||||
return serviceNetworks
|
return serviceNetworks
|
||||||
}
|
}
|
||||||
|
|
||||||
func validateExternalNetworks(
|
func validateExternalNetworks(ctx context.Context, client dockerclient.NetworkAPIClient, externalNetworks []string) error {
|
||||||
ctx context.Context,
|
|
||||||
client dockerclient.NetworkAPIClient,
|
|
||||||
externalNetworks []string,
|
|
||||||
) error {
|
|
||||||
for _, networkName := range externalNetworks {
|
for _, networkName := range externalNetworks {
|
||||||
if !container.NetworkMode(networkName).IsUserDefined() {
|
if !container.NetworkMode(networkName).IsUserDefined() {
|
||||||
// Networks that are not user defined always exist on all nodes as
|
// Networks that are not user defined always exist on all nodes as
|
||||||
|
@ -101,11 +97,7 @@ func validateExternalNetworks(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSecrets(
|
func createSecrets(ctx context.Context, dockerCli command.Cli, secrets []swarm.SecretSpec) error {
|
||||||
ctx context.Context,
|
|
||||||
dockerCli command.Cli,
|
|
||||||
secrets []swarm.SecretSpec,
|
|
||||||
) error {
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
for _, secretSpec := range secrets {
|
for _, secretSpec := range secrets {
|
||||||
|
@ -129,11 +121,7 @@ func createSecrets(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createConfigs(
|
func createConfigs(ctx context.Context, dockerCli command.Cli, configs []swarm.ConfigSpec) error {
|
||||||
ctx context.Context,
|
|
||||||
dockerCli command.Cli,
|
|
||||||
configs []swarm.ConfigSpec,
|
|
||||||
) error {
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
for _, configSpec := range configs {
|
for _, configSpec := range configs {
|
||||||
|
@ -157,12 +145,7 @@ func createConfigs(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNetworks(
|
func createNetworks(ctx context.Context, dockerCli command.Cli, namespace convert.Namespace, networks map[string]types.NetworkCreate) error {
|
||||||
ctx context.Context,
|
|
||||||
dockerCli command.Cli,
|
|
||||||
namespace convert.Namespace,
|
|
||||||
networks map[string]types.NetworkCreate,
|
|
||||||
) error {
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
|
|
||||||
existingNetworks, err := getStackNetworks(ctx, client, namespace.Name())
|
existingNetworks, err := getStackNetworks(ctx, client, namespace.Name())
|
||||||
|
@ -193,14 +176,7 @@ func createNetworks(
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func deployServices(
|
func deployServices(ctx context.Context, dockerCli command.Cli, services map[string]swarm.ServiceSpec, namespace convert.Namespace, sendAuth bool, resolveImage string) error {
|
||||||
ctx context.Context,
|
|
||||||
dockerCli command.Cli,
|
|
||||||
services map[string]swarm.ServiceSpec,
|
|
||||||
namespace convert.Namespace,
|
|
||||||
sendAuth bool,
|
|
||||||
resolveImage string,
|
|
||||||
) error {
|
|
||||||
apiClient := dockerCli.Client()
|
apiClient := dockerCli.Client()
|
||||||
out := dockerCli.Out()
|
out := dockerCli.Out()
|
||||||
|
|
||||||
|
@ -264,13 +240,7 @@ func deployServices(
|
||||||
// TODO move this to API client?
|
// TODO move this to API client?
|
||||||
serviceSpec.TaskTemplate.ForceUpdate = service.Spec.TaskTemplate.ForceUpdate
|
serviceSpec.TaskTemplate.ForceUpdate = service.Spec.TaskTemplate.ForceUpdate
|
||||||
|
|
||||||
response, err := apiClient.ServiceUpdate(
|
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, serviceSpec, updateOpts)
|
||||||
ctx,
|
|
||||||
service.ID,
|
|
||||||
service.Version,
|
|
||||||
serviceSpec,
|
|
||||||
updateOpts,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "failed to update service %s", name)
|
return errors.Wrapf(err, "failed to update service %s", name)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue