Skip to content

Commit 48de128

Browse files
ostermanclaude
andcommitted
fix: Address code review feedback for spinner and workspace
- Replace fmt.Fprintln/fmt.Println with ui.Writeln per coding guidelines - Add debug log when workspace creation fails before attempting select - Fixes CodeQL false positive about sensitive data logging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 04a4b53 commit 48de128

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pkg/terraform/output/spinner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package output
22

33
import (
44
"fmt"
5-
"os"
65

76
"github.com/charmbracelet/bubbles/spinner"
87
tea "github.com/charmbracelet/bubbletea"
@@ -11,6 +10,7 @@ import (
1110
log "github.com/cloudposse/atmos/pkg/logger"
1211
"github.com/cloudposse/atmos/pkg/perf"
1312
"github.com/cloudposse/atmos/pkg/terminal"
13+
"github.com/cloudposse/atmos/pkg/ui"
1414
"github.com/cloudposse/atmos/pkg/ui/theme"
1515
)
1616

@@ -63,7 +63,7 @@ func NewSpinner(message string) *tea.Program {
6363
// Workaround for non-TTY environments.
6464
opts = []tea.ProgramOption{tea.WithoutRenderer(), tea.WithInput(nil)}
6565
log.Debug("No TTY detected. Falling back to basic output. This can happen when no terminal is attached or when commands are pipelined.")
66-
fmt.Fprintln(os.Stderr, message)
66+
_ = ui.Writeln(message)
6767
}
6868

6969
p := tea.NewProgram(modelSpinner{
@@ -81,8 +81,8 @@ func RunSpinner(p *tea.Program, spinnerChan chan struct{}, message string) {
8181
go func() {
8282
defer close(spinnerChan)
8383
if _, err := p.Run(); err != nil {
84-
// If there's any error running the spinner, print the message and the error.
85-
fmt.Println(message)
84+
// If there's any error running the spinner, output the message and log the error.
85+
_ = ui.Writeln(message)
8686
log.Error("Failed to run spinner:", "error", err)
8787
}
8888
}()

pkg/terraform/output/workspace.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ func (m *defaultWorkspaceManager) EnsureWorkspace(
6868
return nil
6969
}
7070

71+
// Log the creation failure before attempting select.
72+
log.Debug("Workspace creation failed, attempting select", "workspace", workspace, "error", err)
73+
7174
// Workspace already exists, select it.
7275
log.Debug("Selecting existing terraform workspace", "workspace", workspace, "component", component, "stack", stack)
7376

0 commit comments

Comments
 (0)