Skip to content

Commit

Permalink
chore: remove the retrylog hook from the init view
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Schaatsbergen <[email protected]>
  • Loading branch information
bschaatsbergen committed Nov 1, 2024
1 parent fb87888 commit a909304
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
4 changes: 2 additions & 2 deletions internal/cloud/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ func cliConfigToken(hostname svchost.Hostname, services *disco.Disco) (string, e
// backend to log any connection issues to prevent data loss.
func (b *Cloud) retryLogHook(attemptNum int, resp *http.Response) {
if b.CLI != nil {
retryLogHook := views.NewRetryLoghook(b.View)
if output := retryLogHook.RetryLogHook(attemptNum, resp, true); len(output) > 0 {
h := views.NewRetryLoghook(b.View)
if output := h.RetryLogHook(attemptNum, resp, true); len(output) > 0 {
b.CLI.Output(b.Colorize().Color(output))
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/command/views/hook_retry_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (hook *RetryLogHook) RetryLogHook(attemptNum int, resp *http.Response, colo
if colorize {
return strings.TrimSpace(fmt.Sprintf("[reset][yellow]%s[reset]", msg))
}
return hook.view.colorize.Color(strings.TrimSpace(msg))
return strings.TrimSpace(msg)
}

// The newline in this error is to make it look good in the CLI!
Expand Down
14 changes: 0 additions & 14 deletions internal/command/views/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import (
"time"

"github.com/hashicorp/terraform/internal/command/arguments"
"github.com/hashicorp/terraform/internal/terraform"
"github.com/hashicorp/terraform/internal/tfdiags"
)

// The Init view is used for the init command.
type Init interface {
Diagnostics(diags tfdiags.Diagnostics)
Hooks() []terraform.Hook
Output(messageCode InitMessageCode, params ...any)
LogInitMessage(messageCode InitMessageCode, params ...any)
Log(message string, params ...any)
Expand Down Expand Up @@ -52,12 +50,6 @@ func (v *InitHuman) Diagnostics(diags tfdiags.Diagnostics) {
v.view.Diagnostics(diags)
}

func (v *InitHuman) Hooks() []terraform.Hook {
return []terraform.Hook{
NewRetryLoghook(v.view),
}
}

func (v *InitHuman) Output(messageCode InitMessageCode, params ...any) {
v.view.streams.Println(v.PrepareMessage(messageCode, params...))
}
Expand Down Expand Up @@ -98,12 +90,6 @@ func (v *InitJSON) Diagnostics(diags tfdiags.Diagnostics) {
v.view.Diagnostics(diags)
}

func (v *InitJSON) Hooks() []terraform.Hook {
return []terraform.Hook{
NewRetryLoghook(v.view.view),
}
}

func (v *InitJSON) Output(messageCode InitMessageCode, params ...any) {
// don't add empty messages to json output
preppedMessage := v.PrepareMessage(messageCode, params...)
Expand Down

0 comments on commit a909304

Please sign in to comment.