Skip to content

Commit 91b348a

Browse files
authored
Merge branch 'main' into feature/dev-3131-add-pager-to-atmos-describe-config-command
2 parents c1de851 + f42f14b commit 91b348a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1724
-390
lines changed

cmd/cmd_utils.go

+17-17
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ func processCommandAliases(
181181
Run: func(cmd *cobra.Command, args []string) {
182182
err := cmd.ParseFlags(args)
183183
if err != nil {
184-
u.LogErrorAndExit(err)
184+
log.Fatal(err)
185185
}
186186

187187
commandToRun := fmt.Sprintf("%s %s %s", os.Args[0], aliasCmd, strings.Join(args, " "))
188188
err = e.ExecuteShell(atmosConfig, commandToRun, commandToRun, currentDirPath, nil, false)
189189
if err != nil {
190-
u.LogErrorAndExit(err)
190+
log.Fatal(err)
191191
}
192192
},
193193
}
@@ -337,13 +337,13 @@ func executeCustomCommand(
337337
if fl.Type == "" || fl.Type == "string" {
338338
providedFlag, err := flags.GetString(fl.Name)
339339
if err != nil {
340-
u.LogErrorAndExit(err)
340+
log.Fatal(err)
341341
}
342342
flagsData[fl.Name] = providedFlag
343343
} else if fl.Type == "bool" {
344344
boolFlag, err := flags.GetBool(fl.Name)
345345
if err != nil {
346-
u.LogErrorAndExit(err)
346+
log.Fatal(err)
347347
}
348348
flagsData[fl.Name] = boolFlag
349349
}
@@ -362,7 +362,7 @@ func executeCustomCommand(
362362
// Process Go templates in the command's 'component_config.component'
363363
component, err := e.ProcessTmpl(fmt.Sprintf("component-config-component-%d", i), commandConfig.ComponentConfig.Component, data, false)
364364
if err != nil {
365-
u.LogErrorAndExit(err)
365+
log.Fatal(err)
366366
}
367367
if component == "" || component == "<no value>" {
368368
u.LogErrorAndExit(fmt.Errorf("the command defines an invalid 'component_config.component: %s' in '%s'",
@@ -372,7 +372,7 @@ func executeCustomCommand(
372372
// Process Go templates in the command's 'component_config.stack'
373373
stack, err := e.ProcessTmpl(fmt.Sprintf("component-config-stack-%d", i), commandConfig.ComponentConfig.Stack, data, false)
374374
if err != nil {
375-
u.LogErrorAndExit(err)
375+
log.Fatal(err)
376376
}
377377
if stack == "" || stack == "<no value>" {
378378
u.LogErrorAndExit(fmt.Errorf("the command defines an invalid 'component_config.stack: %s' in '%s'",
@@ -382,7 +382,7 @@ func executeCustomCommand(
382382
// Get the config for the component in the stack
383383
componentConfig, err := e.ExecuteDescribeComponent(component, stack, true, true, nil)
384384
if err != nil {
385-
u.LogErrorAndExit(err)
385+
log.Fatal(err)
386386
}
387387
data["ComponentConfig"] = componentConfig
388388
}
@@ -399,29 +399,29 @@ func executeCustomCommand(
399399
err = fmt.Errorf("either 'value' or 'valueCommand' can be specified for the ENV var, but not both.\n"+
400400
"Custom command '%s %s' defines 'value=%s' and 'valueCommand=%s' for the ENV var '%s'",
401401
parentCommand.Name(), commandConfig.Name, value, valCommand, key)
402-
u.LogErrorAndExit(err)
402+
log.Fatal(err)
403403
}
404404

405405
// If the command to get the value for the ENV var is provided, execute it
406406
if valCommand != "" {
407407
valCommandName := fmt.Sprintf("env-var-%s-valcommand", key)
408-
res, err := e.ExecuteShellAndReturnOutput(atmosConfig, valCommand, valCommandName, currentDirPath, nil, false)
408+
res, err := u.ExecuteShellAndReturnOutput(valCommand, valCommandName, currentDirPath, nil, false)
409409
if err != nil {
410-
u.LogErrorAndExit(err)
410+
log.Fatal(err)
411411
}
412412
value = strings.TrimRight(res, "\r\n")
413413
} else {
414414
// Process Go templates in the values of the command's ENV vars
415415
value, err = e.ProcessTmpl(fmt.Sprintf("env-var-%d", i), value, data, false)
416416
if err != nil {
417-
u.LogErrorAndExit(err)
417+
log.Fatal(err)
418418
}
419419
}
420420

421421
envVarsList = append(envVarsList, fmt.Sprintf("%s=%s", key, value))
422422
err = os.Setenv(key, value)
423423
if err != nil {
424-
u.LogErrorAndExit(err)
424+
log.Fatal(err)
425425
}
426426
}
427427

@@ -436,14 +436,14 @@ func executeCustomCommand(
436436
// Steps support Go templates and have access to {{ .ComponentConfig.xxx.yyy.zzz }} Go template variables
437437
commandToRun, err := e.ProcessTmpl(fmt.Sprintf("step-%d", i), step, data, false)
438438
if err != nil {
439-
u.LogErrorAndExit(err)
439+
log.Fatal(err)
440440
}
441441

442442
// Execute the command step
443443
commandName := fmt.Sprintf("%s-step-%d", commandConfig.Name, i)
444444
err = e.ExecuteShell(atmosConfig, commandToRun, commandName, currentDirPath, envVarsList, false)
445445
if err != nil {
446-
u.LogErrorAndExit(err)
446+
log.Fatal(err)
447447
}
448448
}
449449
}
@@ -505,7 +505,7 @@ func checkAtmosConfig(opts ...AtmosValidateOption) {
505505

506506
atmosConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, false)
507507
if err != nil {
508-
u.LogErrorAndExit(err)
508+
log.Fatal(err)
509509
}
510510

511511
if vCfg.CheckStack {
@@ -525,7 +525,7 @@ func printMessageForMissingAtmosConfig(atmosConfig schema.AtmosConfiguration) {
525525
fmt.Println()
526526
err := tuiUtils.PrintStyledText("ATMOS")
527527
if err != nil {
528-
u.LogErrorAndExit(err)
528+
log.Fatal(err)
529529
}
530530

531531
// Check if we're in a git repo. Warn if not.
@@ -668,7 +668,7 @@ func getConfigAndStacksInfo(commandName string, cmd *cobra.Command, args []strin
668668

669669
info, err := e.ProcessCommandLineArgs(commandName, cmd, finalArgs, argsAfterDoubleDash)
670670
if err != nil {
671-
u.LogErrorAndExit(err)
671+
log.Fatal(err)
672672
}
673673
return info
674674
}

examples/quick-start-advanced/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG GEODESIC_OS=debian
66
# https://atmos.tools/
77
# https://github.com/cloudposse/atmos
88
# https://github.com/cloudposse/atmos/releases
9-
ARG ATMOS_VERSION=1.172.0
9+
ARG ATMOS_VERSION=1.173.0
1010

1111
# Terraform: https://github.com/hashicorp/terraform/releases
1212
ARG TF_VERSION=1.5.7

internal/exec/describe_component.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
u "github.com/cloudposse/atmos/pkg/utils"
1111
)
1212

13-
// ExecuteDescribeComponentCmd executes `describe component` command
13+
// ExecuteDescribeComponentCmd executes `describe component` command.
1414
func ExecuteDescribeComponentCmd(cmd *cobra.Command, args []string) error {
1515
if len(args) != 1 {
1616
return errors.New("invalid arguments. The command requires one argument `component`")
@@ -106,26 +106,30 @@ func ExecuteDescribeComponent(
106106
var configAndStacksInfo schema.ConfigAndStacksInfo
107107
configAndStacksInfo.ComponentFromArg = component
108108
configAndStacksInfo.Stack = stack
109+
configAndStacksInfo.ComponentSection = make(map[string]any)
109110

110111
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
111112
if err != nil {
112113
return nil, err
113114
}
114115

115-
configAndStacksInfo.ComponentType = "terraform"
116+
configAndStacksInfo.ComponentType = cfg.TerraformComponentType
116117
configAndStacksInfo, err = ProcessStacks(atmosConfig, configAndStacksInfo, true, processTemplates, processYamlFunctions, skip)
118+
configAndStacksInfo.ComponentSection[cfg.ComponentTypeSectionName] = cfg.TerraformComponentType
117119
if err != nil {
118-
configAndStacksInfo.ComponentType = "helmfile"
120+
configAndStacksInfo.ComponentType = cfg.HelmfileComponentType
119121
configAndStacksInfo, err = ProcessStacks(atmosConfig, configAndStacksInfo, true, processTemplates, processYamlFunctions, skip)
122+
configAndStacksInfo.ComponentSection[cfg.ComponentTypeSectionName] = cfg.HelmfileComponentType
120123
if err != nil {
124+
configAndStacksInfo.ComponentSection[cfg.ComponentTypeSectionName] = ""
121125
return nil, err
122126
}
123127
}
124128

125129
return configAndStacksInfo.ComponentSection, nil
126130
}
127131

128-
// FilterAbstractComponents This function removes abstract components and returns the list of components
132+
// FilterAbstractComponents This function removes abstract components and returns the list of components.
129133
func FilterAbstractComponents(componentsMap map[string]any) []string {
130134
if componentsMap == nil {
131135
return []string{}

0 commit comments

Comments
 (0)