Skip to content

Commit 5c6313d

Browse files
committed
updates
1 parent 3e9080a commit 5c6313d

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

internal/exec/template_funcs_component.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717
)
1818

1919
func componentFunc(cliConfig schema.CliConfiguration, component string, stack string) (any, error) {
20-
u.LogTrace(cliConfig, fmt.Sprintf("Executing template function atmos.Component(%s, %s)", component, stack))
20+
u.LogTrace(cliConfig, fmt.Sprintf("Executing template function 'atmos.Component(%s, %s)'", component, stack))
2121

2222
stackSlug := fmt.Sprintf("%s-%s", stack, component)
2323

@@ -82,9 +82,26 @@ func componentFunc(cliConfig schema.CliConfiguration, component string, stack st
8282
return nil, err
8383
}
8484

85+
if cliConfig.Logs.Level == u.LogLevelTrace {
86+
y, err2 := u.ConvertToYAML(outputMeta)
87+
if err2 != nil {
88+
u.LogError(err2)
89+
}
90+
u.LogTrace(cliConfig, fmt.Sprintf("\nResult of 'atmos terraform output %s -s %s' before processing it:\n%s\n", component, stack, y))
91+
}
92+
8593
outputMetaProcessed := lo.MapEntries(outputMeta, func(k string, v tfexec.OutputMeta) (string, any) {
86-
d, err2 := u.ConvertFromJSON(string(v.Value))
87-
u.LogError(err2)
94+
s := string(v.Value)
95+
u.LogTrace(cliConfig, fmt.Sprintf("Converting the variable %s from JSON to string representation\n", s))
96+
97+
d, err2 := u.ConvertFromJSON(s)
98+
99+
if err2 != nil {
100+
u.LogError(err2)
101+
}
102+
103+
u.LogTrace(cliConfig, fmt.Sprintf("Converted the variable %s from JSON to string representation.\nResult: %s\n", s, d))
104+
88105
return k, d
89106
})
90107

@@ -98,11 +115,13 @@ func componentFunc(cliConfig schema.CliConfiguration, component string, stack st
98115
componentFuncSyncMap.Store(stackSlug, sections)
99116

100117
if cliConfig.Logs.Level == u.LogLevelTrace {
101-
u.LogTrace(cliConfig, fmt.Sprintf("Executed template function atmos.Component(%s, %s)\n'outputs' section:\n", component, stack))
102-
err2 := u.PrintAsYAML(outputMetaProcessed)
118+
u.LogTrace(cliConfig, fmt.Sprintf("Executed template function 'atmos.Component(%s, %s)'\n\n'outputs' section:", component, stack))
119+
y, err2 := u.ConvertToYAML(outputMetaProcessed)
103120
if err2 != nil {
104121
u.LogError(err2)
105122
}
123+
u.LogTrace(cliConfig, y)
124+
u.LogTrace(cliConfig, "\n")
106125
}
107126

108127
return sections, nil

0 commit comments

Comments
 (0)