Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
aknysh committed Feb 10, 2025
1 parent 75f88de commit 7696cd4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
34 changes: 22 additions & 12 deletions internal/exec/terraform_outputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,25 +272,31 @@ func GetTerraformOutput(

message := fmt.Sprintf("Fetching %s output from %s in %s", output, component, stack)

// Initialize spinner
p := NewSpinner(message)
spinnerDone := make(chan struct{})
// Run spinner in a goroutine
RunSpinner(p, spinnerDone, message)
// Ensure spinner is stopped before returning
defer StopSpinner(p, spinnerDone)
if atmosConfig.Logs.Level == u.LogLevelTrace || atmosConfig.Logs.Level == u.LogLevelDebug {
// Initialize spinner
p := NewSpinner(message)
spinnerDone := make(chan struct{})
// Run spinner in a goroutine
RunSpinner(p, spinnerDone, message)
// Ensure spinner is stopped before returning
defer StopSpinner(p, spinnerDone)
}

sections, err := ExecuteDescribeComponent(component, stack, true, true, nil)
if err != nil {
fmt.Printf("\r✗ %s\n", message)
if atmosConfig.Logs.Level == u.LogLevelTrace || atmosConfig.Logs.Level == u.LogLevelDebug {
fmt.Printf("\r✗ %s\n", message)
}
l.Fatal("Failed to describe the component", "component", component, "stack", stack, "error", err)
}

// Check if the component in the stack is configured with the 'static' remote state backend, in which case get the
// `output` from the static remote state instead of executing `terraform output`
remoteStateBackendStaticTypeOutputs, err := GetComponentRemoteStateBackendStaticType(sections)
if err != nil {
fmt.Printf("\r✗ %s\n", message)
if atmosConfig.Logs.Level == u.LogLevelTrace || atmosConfig.Logs.Level == u.LogLevelDebug {
fmt.Printf("\r✗ %s\n", message)
}
l.Fatal("Failed to get remote state backend static type outputs", "error", err)
}

Expand All @@ -303,7 +309,9 @@ func GetTerraformOutput(
// Execute `terraform output`
terraformOutputs, err := execTerraformOutput(atmosConfig, component, stack, sections)
if err != nil {
fmt.Printf("\r✗ %s\n", message)
if atmosConfig.Logs.Level == u.LogLevelTrace || atmosConfig.Logs.Level == u.LogLevelDebug {
fmt.Printf("\r✗ %s\n", message)
}
l.Fatal("Failed to execute terraform output", "component", component, "stack", stack, "error", err)
}

Expand All @@ -312,8 +320,10 @@ func GetTerraformOutput(
result = getTerraformOutputVariable(atmosConfig, component, stack, terraformOutputs, output)
}

// Show success
fmt.Printf("\r✓ %s\n", message)
if atmosConfig.Logs.Level == u.LogLevelTrace || atmosConfig.Logs.Level == u.LogLevelDebug {
// Show success
fmt.Printf("\r✓ %s\n", message)
}

return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ components:
vars:
enabled: true
name: "test"
env:
TEST1: a
TEST2: b

0 comments on commit 7696cd4

Please sign in to comment.