@@ -180,7 +180,7 @@ func getInstallClusterConfig(awsCreds AWSCredentials, envName string, disallowPr
180
180
return clusterConfig , nil
181
181
}
182
182
183
- func getClusterConfigureConfig (cachedClusterConfig clusterconfig.Config , awsCreds AWSCredentials , disallowPrompt bool ) (* clusterconfig.Config , error ) {
183
+ func getConfigureClusterConfig (cachedClusterConfig clusterconfig.Config , awsCreds AWSCredentials , disallowPrompt bool ) (* clusterconfig.Config , error ) {
184
184
userClusterConfig := & clusterconfig.Config {}
185
185
var awsClient * aws.Client
186
186
@@ -215,131 +215,144 @@ func getClusterConfigureConfig(cachedClusterConfig clusterconfig.Config, awsCred
215
215
}
216
216
promptIfNotAdmin (awsClient , disallowPrompt )
217
217
218
- if userClusterConfig .Bucket != "" && userClusterConfig .Bucket != cachedClusterConfig .Bucket {
219
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .BucketKey , cachedClusterConfig .Bucket )
218
+ err = setConfigFieldsFromCached (userClusterConfig , & cachedClusterConfig , awsClient )
219
+ if err != nil {
220
+ return nil , err
220
221
}
221
- userClusterConfig .Bucket = cachedClusterConfig .Bucket
222
222
223
- if userClusterConfig .LogGroup != "" && userClusterConfig .LogGroup != cachedClusterConfig .LogGroup {
224
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .LogGroupKey , cachedClusterConfig .LogGroup )
223
+ err = clusterconfig .ConfigurePrompt (userClusterConfig , & cachedClusterConfig , true , disallowPrompt )
224
+ if err != nil {
225
+ return nil , err
225
226
}
226
- userClusterConfig . LogGroup = cachedClusterConfig . LogGroup
227
+ }
227
228
228
- if userClusterConfig .InstanceType != nil && * userClusterConfig .InstanceType != * cachedClusterConfig .InstanceType {
229
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceTypeKey , * cachedClusterConfig .InstanceType )
230
- }
231
- userClusterConfig .InstanceType = cachedClusterConfig .InstanceType
229
+ var err error
230
+ userClusterConfig .Telemetry , err = readTelemetryConfig ()
231
+ if err != nil {
232
+ return nil , err
233
+ }
232
234
233
- if ! reflect .DeepEqual (userClusterConfig .Tags , cachedClusterConfig .Tags ) {
234
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .TagsKey , s .ObjFlat (* & cachedClusterConfig .Tags ))
235
+ err = userClusterConfig .Validate (awsClient )
236
+ if err != nil {
237
+ if _flagClusterConfig != "" {
238
+ err = errors .Wrap (err , _flagClusterConfig )
235
239
}
240
+ return nil , err
241
+ }
236
242
237
- if len (userClusterConfig .AvailabilityZones ) > 0 && ! strset .New (userClusterConfig .AvailabilityZones ... ).IsEqual (strset .New (cachedClusterConfig .AvailabilityZones ... )) {
238
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .AvailabilityZonesKey , cachedClusterConfig .AvailabilityZones )
239
- }
240
- userClusterConfig .AvailabilityZones = cachedClusterConfig .AvailabilityZones
243
+ confirmConfigureClusterConfig (* userClusterConfig , awsCreds , awsClient , disallowPrompt )
241
244
242
- if userClusterConfig .InstanceVolumeSize != cachedClusterConfig .InstanceVolumeSize {
243
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeSizeKey , cachedClusterConfig .InstanceVolumeSize )
244
- }
245
- userClusterConfig .InstanceVolumeSize = cachedClusterConfig .InstanceVolumeSize
245
+ return userClusterConfig , nil
246
+ }
246
247
247
- if userClusterConfig .InstanceVolumeType != cachedClusterConfig .InstanceVolumeType {
248
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeTypeKey , cachedClusterConfig .InstanceVolumeType )
249
- }
250
- userClusterConfig .InstanceVolumeType = cachedClusterConfig .InstanceVolumeType
248
+ func setConfigFieldsFromCached (userClusterConfig * clusterconfig.Config , cachedClusterConfig * clusterconfig.Config , awsClient * aws.Client ) error {
249
+ if userClusterConfig .Bucket != "" && userClusterConfig .Bucket != cachedClusterConfig .Bucket {
250
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .BucketKey , cachedClusterConfig .Bucket )
251
+ }
252
+ userClusterConfig .Bucket = cachedClusterConfig .Bucket
251
253
252
- if userClusterConfig .InstanceVolumeIOPS != cachedClusterConfig .InstanceVolumeIOPS {
253
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeIOPSKey , cachedClusterConfig .InstanceVolumeIOPS )
254
- }
255
- userClusterConfig .InstanceVolumeIOPS = cachedClusterConfig .InstanceVolumeIOPS
254
+ if userClusterConfig .LogGroup != "" && userClusterConfig . LogGroup != cachedClusterConfig .LogGroup {
255
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .LogGroupKey , cachedClusterConfig .LogGroup )
256
+ }
257
+ userClusterConfig .LogGroup = cachedClusterConfig .LogGroup
256
258
257
- if userClusterConfig .SubnetVisibility != cachedClusterConfig .SubnetVisibility {
258
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .SubnetVisibilityKey , cachedClusterConfig .SubnetVisibility )
259
- }
260
- userClusterConfig .SubnetVisibility = cachedClusterConfig .SubnetVisibility
259
+ if userClusterConfig .InstanceType != nil && * userClusterConfig . InstanceType != * cachedClusterConfig .InstanceType {
260
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceTypeKey , * cachedClusterConfig .InstanceType )
261
+ }
262
+ userClusterConfig .InstanceType = cachedClusterConfig .InstanceType
261
263
262
- if userClusterConfig .NATGateway != cachedClusterConfig .NATGateway {
263
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .NATGatewayKey , cachedClusterConfig .NATGateway )
264
- }
265
- userClusterConfig .NATGateway = cachedClusterConfig .NATGateway
264
+ if _ , ok := userClusterConfig .Tags [clusterconfig .ClusterNameTag ]; ! ok {
265
+ userClusterConfig .Tags [clusterconfig .ClusterNameTag ] = userClusterConfig .ClusterName
266
+ }
267
+ if ! reflect .DeepEqual (userClusterConfig .Tags , cachedClusterConfig .Tags ) {
268
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .TagsKey , s .ObjFlat (cachedClusterConfig .Tags ))
269
+ }
266
270
267
- if userClusterConfig .APILoadBalancerScheme != cachedClusterConfig .APILoadBalancerScheme {
268
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .APILoadBalancerSchemeKey , cachedClusterConfig .APILoadBalancerScheme )
269
- }
270
- userClusterConfig .APILoadBalancerScheme = cachedClusterConfig .APILoadBalancerScheme
271
+ if len ( userClusterConfig .AvailabilityZones ) > 0 && ! strset . New ( userClusterConfig . AvailabilityZones ... ). IsEqual ( strset . New ( cachedClusterConfig .AvailabilityZones ... )) {
272
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .AvailabilityZonesKey , cachedClusterConfig .AvailabilityZones )
273
+ }
274
+ userClusterConfig .AvailabilityZones = cachedClusterConfig .AvailabilityZones
271
275
272
- if userClusterConfig .OperatorLoadBalancerScheme != cachedClusterConfig .OperatorLoadBalancerScheme {
273
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OperatorLoadBalancerSchemeKey , cachedClusterConfig .OperatorLoadBalancerScheme )
274
- }
275
- userClusterConfig .OperatorLoadBalancerScheme = cachedClusterConfig .OperatorLoadBalancerScheme
276
+ if userClusterConfig .InstanceVolumeSize != cachedClusterConfig .InstanceVolumeSize {
277
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeSizeKey , cachedClusterConfig .InstanceVolumeSize )
278
+ }
279
+ userClusterConfig .InstanceVolumeSize = cachedClusterConfig .InstanceVolumeSize
276
280
277
- if userClusterConfig .Spot != nil && * userClusterConfig . Spot != * cachedClusterConfig .Spot {
278
- return nil , clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .SpotKey , * cachedClusterConfig .Spot )
279
- }
280
- userClusterConfig .Spot = cachedClusterConfig .Spot
281
+ if userClusterConfig .InstanceVolumeType != cachedClusterConfig .InstanceVolumeType {
282
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeTypeKey , cachedClusterConfig .InstanceVolumeType )
283
+ }
284
+ userClusterConfig .InstanceVolumeType = cachedClusterConfig .InstanceVolumeType
281
285
282
- if userClusterConfig .Spot != nil && * userClusterConfig .Spot {
283
- err = userClusterConfig .FillEmptySpotFields (awsClient )
284
- if err != nil {
285
- return nil , err
286
- }
287
- }
286
+ if userClusterConfig .InstanceVolumeIOPS != cachedClusterConfig .InstanceVolumeIOPS {
287
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceVolumeIOPSKey , cachedClusterConfig .InstanceVolumeIOPS )
288
+ }
289
+ userClusterConfig .InstanceVolumeIOPS = cachedClusterConfig .InstanceVolumeIOPS
288
290
289
- if userClusterConfig .SpotConfig != nil && s . Obj ( userClusterConfig . SpotConfig ) != s . Obj ( cachedClusterConfig .SpotConfig ) {
290
- if cachedClusterConfig . SpotConfig == nil {
291
- return nil , clusterconfig . ErrorConfiguredWhenSpotIsNotEnabled ( clusterconfig . SpotConfigKey )
292
- }
291
+ if userClusterConfig .SubnetVisibility != cachedClusterConfig .SubnetVisibility {
292
+ return clusterconfig . ErrorConfigCannotBeChangedOnUpdate ( clusterconfig . SubnetVisibilityKey , cachedClusterConfig . SubnetVisibility )
293
+ }
294
+ userClusterConfig . SubnetVisibility = cachedClusterConfig . SubnetVisibility
293
295
294
- if ! strset .New (userClusterConfig .SpotConfig .InstanceDistribution ... ).IsEqual (strset .New (cachedClusterConfig .SpotConfig .InstanceDistribution ... )) {
295
- return nil , errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceDistributionKey , cachedClusterConfig .SpotConfig .InstanceDistribution ), clusterconfig .SpotConfigKey )
296
- }
296
+ if userClusterConfig .NATGateway != cachedClusterConfig .NATGateway {
297
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .NATGatewayKey , cachedClusterConfig .NATGateway )
298
+ }
299
+ userClusterConfig .NATGateway = cachedClusterConfig .NATGateway
297
300
298
- if userClusterConfig .SpotConfig .OnDemandBaseCapacity != nil && * userClusterConfig .SpotConfig .OnDemandBaseCapacity != * cachedClusterConfig .SpotConfig .OnDemandBaseCapacity {
299
- return nil , errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OnDemandBaseCapacityKey , * cachedClusterConfig .SpotConfig .OnDemandBaseCapacity ), clusterconfig .SpotConfigKey )
300
- }
301
+ if userClusterConfig .APILoadBalancerScheme != cachedClusterConfig .APILoadBalancerScheme {
302
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .APILoadBalancerSchemeKey , cachedClusterConfig .APILoadBalancerScheme )
303
+ }
304
+ userClusterConfig .APILoadBalancerScheme = cachedClusterConfig .APILoadBalancerScheme
301
305
302
- if userClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity != nil && * userClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity != * cachedClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity {
303
- return nil , errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OnDemandPercentageAboveBaseCapacityKey , * cachedClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity ), clusterconfig .SpotConfigKey )
304
- }
306
+ if userClusterConfig .OperatorLoadBalancerScheme != cachedClusterConfig .OperatorLoadBalancerScheme {
307
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OperatorLoadBalancerSchemeKey , cachedClusterConfig .OperatorLoadBalancerScheme )
308
+ }
309
+ userClusterConfig .OperatorLoadBalancerScheme = cachedClusterConfig .OperatorLoadBalancerScheme
305
310
306
- if userClusterConfig .SpotConfig .MaxPrice != nil && * userClusterConfig .SpotConfig .MaxPrice != * cachedClusterConfig .SpotConfig .MaxPrice {
307
- return nil , errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .MaxPriceKey , * cachedClusterConfig .SpotConfig .MaxPrice ), clusterconfig .SpotConfigKey )
308
- }
311
+ if userClusterConfig .Spot != nil && * userClusterConfig .Spot != * cachedClusterConfig .Spot {
312
+ return clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .SpotKey , * cachedClusterConfig .Spot )
313
+ }
314
+ userClusterConfig .Spot = cachedClusterConfig .Spot
309
315
310
- if userClusterConfig .SpotConfig .InstancePools != nil && * userClusterConfig .SpotConfig .InstancePools != * cachedClusterConfig .SpotConfig .InstancePools {
311
- return nil , errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstancePoolsKey , * cachedClusterConfig .SpotConfig .InstancePools ), clusterconfig .SpotConfigKey )
312
- }
316
+ if userClusterConfig .Spot != nil && * userClusterConfig .Spot {
317
+ err := userClusterConfig .FillEmptySpotFields (awsClient )
318
+ if err != nil {
319
+ return err
320
+ }
321
+ }
313
322
314
- if userClusterConfig .SpotConfig . OnDemandBackup != cachedClusterConfig .SpotConfig . OnDemandBackup {
315
- return nil , errors . Wrap ( clusterconfig . ErrorConfigCannotBeChangedOnUpdate ( clusterconfig . OnDemandBackupKey , cachedClusterConfig .SpotConfig . OnDemandBackup ), clusterconfig . SpotConfigKey )
316
- }
323
+ if userClusterConfig .SpotConfig != nil && s . Obj ( userClusterConfig . SpotConfig ) != s . Obj ( cachedClusterConfig .SpotConfig ) {
324
+ if cachedClusterConfig .SpotConfig == nil {
325
+ return clusterconfig . ErrorConfiguredWhenSpotIsNotEnabled ( clusterconfig . SpotConfigKey )
317
326
}
318
- userClusterConfig .SpotConfig = cachedClusterConfig .SpotConfig
319
327
320
- err = clusterconfig .ConfigurePrompt (userClusterConfig , & cachedClusterConfig , true , disallowPrompt )
321
- if err != nil {
322
- return nil , err
328
+ if ! strset .New (userClusterConfig .SpotConfig .InstanceDistribution ... ).IsEqual (strset .New (cachedClusterConfig .SpotConfig .InstanceDistribution ... )) {
329
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstanceDistributionKey , cachedClusterConfig .SpotConfig .InstanceDistribution ), clusterconfig .SpotConfigKey )
323
330
}
324
- }
325
331
326
- var err error
327
- userClusterConfig .Telemetry , err = readTelemetryConfig ()
328
- if err != nil {
329
- return nil , err
330
- }
332
+ if userClusterConfig .SpotConfig .OnDemandBaseCapacity != nil && * userClusterConfig .SpotConfig .OnDemandBaseCapacity != * cachedClusterConfig .SpotConfig .OnDemandBaseCapacity {
333
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OnDemandBaseCapacityKey , * cachedClusterConfig .SpotConfig .OnDemandBaseCapacity ), clusterconfig .SpotConfigKey )
334
+ }
331
335
332
- err = userClusterConfig .Validate (awsClient )
333
- if err != nil {
334
- if _flagClusterConfig != "" {
335
- err = errors .Wrap (err , _flagClusterConfig )
336
+ if userClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity != nil && * userClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity != * cachedClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity {
337
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OnDemandPercentageAboveBaseCapacityKey , * cachedClusterConfig .SpotConfig .OnDemandPercentageAboveBaseCapacity ), clusterconfig .SpotConfigKey )
338
+ }
339
+
340
+ if userClusterConfig .SpotConfig .MaxPrice != nil && * userClusterConfig .SpotConfig .MaxPrice != * cachedClusterConfig .SpotConfig .MaxPrice {
341
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .MaxPriceKey , * cachedClusterConfig .SpotConfig .MaxPrice ), clusterconfig .SpotConfigKey )
342
+ }
343
+
344
+ if userClusterConfig .SpotConfig .InstancePools != nil && * userClusterConfig .SpotConfig .InstancePools != * cachedClusterConfig .SpotConfig .InstancePools {
345
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .InstancePoolsKey , * cachedClusterConfig .SpotConfig .InstancePools ), clusterconfig .SpotConfigKey )
346
+ }
347
+
348
+ if userClusterConfig .SpotConfig .OnDemandBackup != cachedClusterConfig .SpotConfig .OnDemandBackup {
349
+ return errors .Wrap (clusterconfig .ErrorConfigCannotBeChangedOnUpdate (clusterconfig .OnDemandBackupKey , cachedClusterConfig .SpotConfig .OnDemandBackup ), clusterconfig .SpotConfigKey )
336
350
}
337
- return nil , err
338
351
}
339
352
340
- confirmConfigureClusterConfig ( * userClusterConfig , awsCreds , awsClient , disallowPrompt )
353
+ userClusterConfig . SpotConfig = cachedClusterConfig . SpotConfig
341
354
342
- return userClusterConfig , nil
355
+ return nil
343
356
}
344
357
345
358
func confirmInstallClusterConfig (clusterConfig * clusterconfig.Config , awsCreds AWSCredentials , awsClient * aws.Client , envName string , disallowPrompt bool ) {
0 commit comments