Skip to content

Commit c2e2d77

Browse files
authored
Update cluster configure nodegroup messages (#2289)
1 parent 28d4d9d commit c2e2d77

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

cli/cmd/lib_cluster_config.go

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -280,36 +280,32 @@ func confirmInstallClusterConfig(clusterConfig *clusterconfig.Config, awsClient
280280

281281
func confirmConfigureClusterConfig(configureChanges clusterconfig.ConfigureChanges, oldCc, newCc clusterconfig.Config, disallowPrompt bool) {
282282
fmt.Printf("your %s cluster in region %s will be updated as follows:\n\n", newCc.ClusterName, newCc.Region)
283-
if len(configureChanges.NodeGroupsToScale) > 0 {
284-
fmt.Printf("○ %d %s will be scaled\n", len(configureChanges.NodeGroupsToScale), s.PluralS("nodegroup", len(configureChanges.NodeGroupsToScale)))
285-
for _, ngName := range configureChanges.NodeGroupsToScale {
286-
var output string
287-
ngOld := oldCc.GetNodeGroupByName(ngName)
288-
ngScaled := newCc.GetNodeGroupByName(ngName)
289-
if ngOld.MinInstances != ngScaled.MinInstances && ngOld.MaxInstances != ngScaled.MaxInstances {
290-
output = fmt.Sprintf("nodegroup %s will update its %s from %d to %d and update its %s from %d to %d", ngName, clusterconfig.MinInstancesKey, ngOld.MinInstances, ngScaled.MinInstances, clusterconfig.MaxInstancesKey, ngOld.MaxInstances, ngScaled.MaxInstances)
291-
}
292-
if ngOld.MinInstances == ngScaled.MinInstances && ngOld.MaxInstances != ngScaled.MaxInstances {
293-
output = fmt.Sprintf("nodegroup %s will update its %s from %d to %d", ngName, clusterconfig.MaxInstancesKey, ngOld.MaxInstances, ngScaled.MaxInstances)
294-
}
295-
if ngOld.MinInstances != ngScaled.MinInstances && ngOld.MaxInstances == ngScaled.MaxInstances {
296-
output = fmt.Sprintf("nodegroup %s will update its %s from %d to %d", ngName, clusterconfig.MinInstancesKey, ngOld.MinInstances, ngScaled.MinInstances)
297-
}
298-
fmt.Printf(" ○ %s\n", output)
283+
284+
for _, ngName := range configureChanges.NodeGroupsToScale {
285+
ngOld := oldCc.GetNodeGroupByName(ngName)
286+
ngScaled := newCc.GetNodeGroupByName(ngName)
287+
if ngOld.MinInstances != ngScaled.MinInstances && ngOld.MaxInstances != ngScaled.MaxInstances {
288+
fmt.Printf("○ nodegroup %s will update %s from %d to %d and %s from %d to %d\n", ngName, clusterconfig.MinInstancesKey, ngOld.MinInstances, ngScaled.MinInstances, clusterconfig.MaxInstancesKey, ngOld.MaxInstances, ngScaled.MaxInstances)
289+
} else if ngOld.MinInstances == ngScaled.MinInstances && ngOld.MaxInstances != ngScaled.MaxInstances {
290+
fmt.Printf("○ nodegroup %s will update %s from %d to %d\n", ngName, clusterconfig.MaxInstancesKey, ngOld.MaxInstances, ngScaled.MaxInstances)
291+
} else if ngOld.MinInstances != ngScaled.MinInstances && ngOld.MaxInstances == ngScaled.MaxInstances {
292+
fmt.Printf("○ nodegroup %s will update %s from %d to %d\n", ngName, clusterconfig.MinInstancesKey, ngOld.MinInstances, ngScaled.MinInstances)
299293
}
300294
}
301-
if len(configureChanges.NodeGroupsToAdd) > 0 {
302-
fmt.Printf("○ %d %s will be added: %s\n", len(configureChanges.NodeGroupsToAdd), s.PluralS("nodegroup", len(configureChanges.NodeGroupsToAdd)), s.StrsAnd(configureChanges.NodeGroupsToAdd))
295+
296+
for _, ngName := range configureChanges.NodeGroupsToAdd {
297+
fmt.Printf("○ nodegroup %s will be added\n", ngName)
303298
}
304-
if len(configureChanges.NodeGroupsToRemove) > 0 {
305-
fmt.Printf("○ %d %s will be removed: %s\n", len(configureChanges.NodeGroupsToRemove), s.PluralS("nodegroup", len(configureChanges.NodeGroupsToRemove)), s.StrsAnd(configureChanges.NodeGroupsToRemove))
299+
300+
for _, ngName := range configureChanges.NodeGroupsToRemove {
301+
fmt.Printf("○ nodegroup %s will be removed\n", ngName)
306302
}
307-
// EKS node groups that don't appear in the old/new cluster config
308-
// this is unlikely but can happen
309-
ghostEKSNodeGroups := configureChanges.GetGhostEKSNodeGroups()
310-
if len(ghostEKSNodeGroups) > 0 {
311-
fmt.Printf("○ %d %s will be removed: %s\n", len(ghostEKSNodeGroups), s.PluralS("EKS nodegroup", len(ghostEKSNodeGroups)), s.StrsAnd(ghostEKSNodeGroups))
303+
304+
// EKS node groups that don't appear in the old/new cluster config; this is unlikely but can happen
305+
for _, ngName := range configureChanges.GetGhostEKSNodeGroups() {
306+
fmt.Printf("○ EKS nodegroup %s will be removed\n", ngName)
312307
}
308+
313309
fmt.Println()
314310

315311
if !disallowPrompt {

0 commit comments

Comments
 (0)