@@ -62,7 +62,7 @@ func processCustomCommands(
62
62
if _ , exist := existingTopLevelCommands [commandConfig .Name ]; exist && topLevel {
63
63
command = existingTopLevelCommands [commandConfig .Name ]
64
64
} else {
65
- var customCommand = & cobra.Command {
65
+ customCommand : = & cobra.Command {
66
66
Use : commandConfig .Name ,
67
67
Short : commandConfig .Description ,
68
68
Long : commandConfig .Description ,
@@ -132,21 +132,21 @@ func processCommandAliases(
132
132
aliasCmd := strings .TrimSpace (v )
133
133
aliasFor := fmt .Sprintf ("alias for '%s'" , aliasCmd )
134
134
135
- var aliasCommand = & cobra.Command {
135
+ aliasCommand : = & cobra.Command {
136
136
Use : alias ,
137
137
Short : aliasFor ,
138
138
Long : aliasFor ,
139
139
FParseErrWhitelist : struct { UnknownFlags bool }{UnknownFlags : true },
140
140
Run : func (cmd * cobra.Command , args []string ) {
141
141
err := cmd .ParseFlags (args )
142
142
if err != nil {
143
- u .LogErrorAndExit (atmosConfig , err )
143
+ u .LogErrorAndExit (err )
144
144
}
145
145
146
146
commandToRun := fmt .Sprintf ("%s %s %s" , os .Args [0 ], aliasCmd , strings .Join (args , " " ))
147
147
err = e .ExecuteShell (atmosConfig , commandToRun , commandToRun , "." , nil , false )
148
148
if err != nil {
149
- u .LogErrorAndExit (atmosConfig , err )
149
+ u .LogErrorAndExit (err )
150
150
}
151
151
},
152
152
}
@@ -170,7 +170,7 @@ func preCustomCommand(
170
170
) {
171
171
var sb strings.Builder
172
172
173
- //checking for zero arguments in config
173
+ // checking for zero arguments in config
174
174
if len (commandConfig .Arguments ) == 0 {
175
175
if len (commandConfig .Steps ) > 0 {
176
176
// do nothing here; let the code proceed
@@ -182,18 +182,18 @@ func preCustomCommand(
182
182
fmt .Sprintf ("%d. %s %s %s\n " , i + 1 , parentCommand .Use , commandConfig .Name , c .Name ),
183
183
)
184
184
}
185
- u .LogInfo (schema. AtmosConfiguration {}, sb .String ())
185
+ u .LogInfo (sb .String ())
186
186
os .Exit (1 )
187
187
} else {
188
188
// truly invalid, nothing to do
189
- u .LogError (schema. AtmosConfiguration {}, errors .New (
189
+ u .LogError (errors .New (
190
190
"invalid command: no args, no steps, no sub-commands" ,
191
191
))
192
192
os .Exit (1 )
193
193
}
194
194
}
195
195
196
- //Check on many arguments required and have no default value
196
+ // Check on many arguments required and have no default value
197
197
requiredNoDefaultCount := 0
198
198
for _ , arg := range commandConfig .Arguments {
199
199
if arg .Required && arg .Default == "" {
@@ -218,7 +218,7 @@ func preCustomCommand(
218
218
if len (args ) > 0 {
219
219
sb .WriteString (fmt .Sprintf ("\n Received %d argument(s): %s\n " , len (args ), strings .Join (args , ", " )))
220
220
}
221
- u .LogErrorAndExit (schema. AtmosConfiguration {}, errors .New (sb .String ()))
221
+ u .LogErrorAndExit (errors .New (sb .String ()))
222
222
}
223
223
224
224
// Merge user-supplied arguments with defaults
@@ -233,7 +233,7 @@ func preCustomCommand(
233
233
} else {
234
234
// This theoretically shouldn't happen:
235
235
sb .WriteString (fmt .Sprintf ("Missing required argument '%s' with no default!\n " , arg .Name ))
236
- u .LogErrorAndExit (schema. AtmosConfiguration {}, errors .New (sb .String ()))
236
+ u .LogErrorAndExit (errors .New (sb .String ()))
237
237
}
238
238
}
239
239
}
@@ -297,20 +297,20 @@ func executeCustomCommand(
297
297
if fl .Type == "" || fl .Type == "string" {
298
298
providedFlag , err := flags .GetString (fl .Name )
299
299
if err != nil {
300
- u .LogErrorAndExit (atmosConfig , err )
300
+ u .LogErrorAndExit (err )
301
301
}
302
302
flagsData [fl .Name ] = providedFlag
303
303
} else if fl .Type == "bool" {
304
304
boolFlag , err := flags .GetBool (fl .Name )
305
305
if err != nil {
306
- u .LogErrorAndExit (atmosConfig , err )
306
+ u .LogErrorAndExit (err )
307
307
}
308
308
flagsData [fl .Name ] = boolFlag
309
309
}
310
310
}
311
311
312
312
// Prepare template data
313
- var data = map [string ]any {
313
+ data : = map [string ]any {
314
314
"Arguments" : argumentsData ,
315
315
"Flags" : flagsData ,
316
316
}
@@ -321,27 +321,27 @@ func executeCustomCommand(
321
321
// Process Go templates in the command's 'component_config.component'
322
322
component , err := e .ProcessTmpl (fmt .Sprintf ("component-config-component-%d" , i ), commandConfig .ComponentConfig .Component , data , false )
323
323
if err != nil {
324
- u .LogErrorAndExit (atmosConfig , err )
324
+ u .LogErrorAndExit (err )
325
325
}
326
326
if component == "" || component == "<no value>" {
327
- u .LogErrorAndExit (atmosConfig , fmt .Errorf ("the command defines an invalid 'component_config.component: %s' in '%s'" ,
327
+ u .LogErrorAndExit (fmt .Errorf ("the command defines an invalid 'component_config.component: %s' in '%s'" ,
328
328
commandConfig .ComponentConfig .Component , cfg .CliConfigFileName + u .DefaultStackConfigFileExtension ))
329
329
}
330
330
331
331
// Process Go templates in the command's 'component_config.stack'
332
332
stack , err := e .ProcessTmpl (fmt .Sprintf ("component-config-stack-%d" , i ), commandConfig .ComponentConfig .Stack , data , false )
333
333
if err != nil {
334
- u .LogErrorAndExit (atmosConfig , err )
334
+ u .LogErrorAndExit (err )
335
335
}
336
336
if stack == "" || stack == "<no value>" {
337
- u .LogErrorAndExit (atmosConfig , fmt .Errorf ("the command defines an invalid 'component_config.stack: %s' in '%s'" ,
337
+ u .LogErrorAndExit (fmt .Errorf ("the command defines an invalid 'component_config.stack: %s' in '%s'" ,
338
338
commandConfig .ComponentConfig .Stack , cfg .CliConfigFileName + u .DefaultStackConfigFileExtension ))
339
339
}
340
340
341
341
// Get the config for the component in the stack
342
342
componentConfig , err := e .ExecuteDescribeComponent (component , stack , true )
343
343
if err != nil {
344
- u .LogErrorAndExit (atmosConfig , err )
344
+ u .LogErrorAndExit (err )
345
345
}
346
346
data ["ComponentConfig" ] = componentConfig
347
347
}
@@ -358,51 +358,51 @@ func executeCustomCommand(
358
358
err = fmt .Errorf ("either 'value' or 'valueCommand' can be specified for the ENV var, but not both.\n " +
359
359
"Custom command '%s %s' defines 'value=%s' and 'valueCommand=%s' for the ENV var '%s'" ,
360
360
parentCommand .Name (), commandConfig .Name , value , valCommand , key )
361
- u .LogErrorAndExit (atmosConfig , err )
361
+ u .LogErrorAndExit (err )
362
362
}
363
363
364
364
// If the command to get the value for the ENV var is provided, execute it
365
365
if valCommand != "" {
366
366
valCommandName := fmt .Sprintf ("env-var-%s-valcommand" , key )
367
367
res , err := e .ExecuteShellAndReturnOutput (atmosConfig , valCommand , valCommandName , "." , nil , false )
368
368
if err != nil {
369
- u .LogErrorAndExit (atmosConfig , err )
369
+ u .LogErrorAndExit (err )
370
370
}
371
371
value = strings .TrimRight (res , "\r \n " )
372
372
} else {
373
373
// Process Go templates in the values of the command's ENV vars
374
374
value , err = e .ProcessTmpl (fmt .Sprintf ("env-var-%d" , i ), value , data , false )
375
375
if err != nil {
376
- u .LogErrorAndExit (atmosConfig , err )
376
+ u .LogErrorAndExit (err )
377
377
}
378
378
}
379
379
380
380
envVarsList = append (envVarsList , fmt .Sprintf ("%s=%s" , key , value ))
381
381
err = os .Setenv (key , value )
382
382
if err != nil {
383
- u .LogErrorAndExit (atmosConfig , err )
383
+ u .LogErrorAndExit (err )
384
384
}
385
385
}
386
386
387
387
if len (envVarsList ) > 0 && commandConfig .Verbose {
388
- u .LogDebug (atmosConfig , "\n Using ENV vars:" )
388
+ u .LogDebug ("\n Using ENV vars:" )
389
389
for _ , v := range envVarsList {
390
- u .LogDebug (atmosConfig , v )
390
+ u .LogDebug (v )
391
391
}
392
392
}
393
393
394
394
// Process Go templates in the command's steps.
395
395
// Steps support Go templates and have access to {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables
396
396
commandToRun , err := e .ProcessTmpl (fmt .Sprintf ("step-%d" , i ), step , data , false )
397
397
if err != nil {
398
- u .LogErrorAndExit (atmosConfig , err )
398
+ u .LogErrorAndExit (err )
399
399
}
400
400
401
401
// Execute the command step
402
402
commandName := fmt .Sprintf ("%s-step-%d" , commandConfig .Name , i )
403
403
err = e .ExecuteShell (atmosConfig , commandToRun , commandName , "." , envVarsList , false )
404
404
if err != nil {
405
- u .LogErrorAndExit (atmosConfig , err )
405
+ u .LogErrorAndExit (err )
406
406
}
407
407
}
408
408
}
@@ -435,7 +435,7 @@ func checkAtmosConfig(opts ...AtmosValidateOption) {
435
435
436
436
atmosConfig , err := cfg .InitCliConfig (schema.ConfigAndStacksInfo {}, false )
437
437
if err != nil {
438
- u .LogErrorAndExit (atmosConfig , err )
438
+ u .LogErrorAndExit (err )
439
439
}
440
440
441
441
if vCfg .CheckStack {
@@ -455,7 +455,7 @@ func printMessageForMissingAtmosConfig(atmosConfig schema.AtmosConfiguration) {
455
455
fmt .Println ()
456
456
err := tuiUtils .PrintStyledText ("ATMOS" )
457
457
if err != nil {
458
- u .LogErrorAndExit (atmosConfig , err )
458
+ u .LogErrorAndExit (err )
459
459
}
460
460
461
461
if atmosConfig .Default {
@@ -501,7 +501,7 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
501
501
// Load the cache
502
502
cacheCfg , err := cfg .LoadCache ()
503
503
if err != nil {
504
- u .LogWarning (atmosConfig , fmt .Sprintf ("Could not load cache: %s" , err ))
504
+ u .LogWarning (fmt .Sprintf ("Could not load cache: %s" , err ))
505
505
return
506
506
}
507
507
@@ -514,12 +514,12 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
514
514
// Get the latest Atmos release from GitHub
515
515
latestReleaseTag , err := u .GetLatestGitHubRepoRelease ("cloudposse" , "atmos" )
516
516
if err != nil {
517
- u .LogWarning (atmosConfig , fmt .Sprintf ("Failed to retrieve latest Atmos release info: %s" , err ))
517
+ u .LogWarning (fmt .Sprintf ("Failed to retrieve latest Atmos release info: %s" , err ))
518
518
return
519
519
}
520
520
521
521
if latestReleaseTag == "" {
522
- u .LogWarning (atmosConfig , "No release information available" )
522
+ u .LogWarning ("No release information available" )
523
523
return
524
524
}
525
525
@@ -535,8 +535,7 @@ func CheckForAtmosUpdateAndPrintMessage(atmosConfig schema.AtmosConfiguration) {
535
535
// Update the cache to mark the current timestamp
536
536
cacheCfg .LastChecked = time .Now ().Unix ()
537
537
if saveErr := cfg .SaveCache (cacheCfg ); saveErr != nil {
538
- u .LogWarning (atmosConfig , fmt .Sprintf ("Unable to save cache: %s" , saveErr ))
539
-
538
+ u .LogWarning (fmt .Sprintf ("Unable to save cache: %s" , saveErr ))
540
539
}
541
540
}
542
541
@@ -554,7 +553,6 @@ func handleHelpRequest(cmd *cobra.Command, args []string) {
554
553
}
555
554
556
555
func showUsageAndExit (cmd * cobra.Command , args []string ) {
557
-
558
556
var suggestions []string
559
557
unknownCommand := fmt .Sprintf ("Error: Unknown command: %q\n \n " , cmd .CommandPath ())
560
558
@@ -593,7 +591,7 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin
593
591
checkAtmosConfig ()
594
592
595
593
var argsAfterDoubleDash []string
596
- var finalArgs = args
594
+ finalArgs : = args
597
595
598
596
doubleDashIndex := lo .IndexOf (args , "--" )
599
597
if doubleDashIndex > 0 {
@@ -603,7 +601,7 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin
603
601
604
602
info , err := e .ProcessCommandLineArgs (commandName , cmd , finalArgs , argsAfterDoubleDash )
605
603
if err != nil {
606
- u .LogErrorAndExit (schema. AtmosConfiguration {}, err )
604
+ u .LogErrorAndExit (err )
607
605
}
608
606
return info
609
607
}
0 commit comments