Skip to content

Commit 047ea37

Browse files
committed
cli/command/stack/swarm: pruneServices: fix typo and minor cleanup
- fix typo in argument name - rename var that shadowed function - pre-allocate slice Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 4f7f42d commit 047ea37

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cli/command/stack/swarm/deploy.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,19 @@ func checkDaemonIsSwarmManager(ctx context.Context, dockerCli command.Cli) error
6969
}
7070

7171
// pruneServices removes services that are no longer referenced in the source
72-
func pruneServices(ctx context.Context, dockerCCLI command.Cli, namespace convert.Namespace, services map[string]struct{}) {
73-
apiClient := dockerCCLI.Client()
72+
func pruneServices(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, services map[string]struct{}) {
73+
apiClient := dockerCLI.Client()
7474

7575
oldServices, err := getStackServices(ctx, apiClient, namespace.Name())
7676
if err != nil {
77-
_, _ = fmt.Fprintln(dockerCCLI.Err(), "Failed to list services:", err)
77+
_, _ = fmt.Fprintln(dockerCLI.Err(), "Failed to list services:", err)
7878
}
7979

80-
pruneServices := []swarm.Service{}
80+
toRemove := make([]swarm.Service, 0, len(oldServices))
8181
for _, service := range oldServices {
8282
if _, exists := services[namespace.Descope(service.Spec.Name)]; !exists {
83-
pruneServices = append(pruneServices, service)
83+
toRemove = append(toRemove, service)
8484
}
8585
}
86-
removeServices(ctx, dockerCCLI, pruneServices)
86+
removeServices(ctx, dockerCLI, toRemove)
8787
}

0 commit comments

Comments
 (0)