@@ -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