Skip to content

Commit a909304

Browse files
chore: remove the retrylog hook from the init view
Signed-off-by: Bruno Schaatsbergen <[email protected]>
1 parent fb87888 commit a909304

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

internal/cloud/backend.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ func cliConfigToken(hostname svchost.Hostname, services *disco.Disco) (string, e
606606
// backend to log any connection issues to prevent data loss.
607607
func (b *Cloud) retryLogHook(attemptNum int, resp *http.Response) {
608608
if b.CLI != nil {
609-
retryLogHook := views.NewRetryLoghook(b.View)
610-
if output := retryLogHook.RetryLogHook(attemptNum, resp, true); len(output) > 0 {
609+
h := views.NewRetryLoghook(b.View)
610+
if output := h.RetryLogHook(attemptNum, resp, true); len(output) > 0 {
611611
b.CLI.Output(b.Colorize().Color(output))
612612
}
613613
}

internal/command/views/hook_retry_log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (hook *RetryLogHook) RetryLogHook(attemptNum int, resp *http.Response, colo
5555
if colorize {
5656
return strings.TrimSpace(fmt.Sprintf("[reset][yellow]%s[reset]", msg))
5757
}
58-
return hook.view.colorize.Color(strings.TrimSpace(msg))
58+
return strings.TrimSpace(msg)
5959
}
6060

6161
// The newline in this error is to make it look good in the CLI!

internal/command/views/init.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ import (
1010
"time"
1111

1212
"github.com/hashicorp/terraform/internal/command/arguments"
13-
"github.com/hashicorp/terraform/internal/terraform"
1413
"github.com/hashicorp/terraform/internal/tfdiags"
1514
)
1615

1716
// The Init view is used for the init command.
1817
type Init interface {
1918
Diagnostics(diags tfdiags.Diagnostics)
20-
Hooks() []terraform.Hook
2119
Output(messageCode InitMessageCode, params ...any)
2220
LogInitMessage(messageCode InitMessageCode, params ...any)
2321
Log(message string, params ...any)
@@ -52,12 +50,6 @@ func (v *InitHuman) Diagnostics(diags tfdiags.Diagnostics) {
5250
v.view.Diagnostics(diags)
5351
}
5452

55-
func (v *InitHuman) Hooks() []terraform.Hook {
56-
return []terraform.Hook{
57-
NewRetryLoghook(v.view),
58-
}
59-
}
60-
6153
func (v *InitHuman) Output(messageCode InitMessageCode, params ...any) {
6254
v.view.streams.Println(v.PrepareMessage(messageCode, params...))
6355
}
@@ -98,12 +90,6 @@ func (v *InitJSON) Diagnostics(diags tfdiags.Diagnostics) {
9890
v.view.Diagnostics(diags)
9991
}
10092

101-
func (v *InitJSON) Hooks() []terraform.Hook {
102-
return []terraform.Hook{
103-
NewRetryLoghook(v.view.view),
104-
}
105-
}
106-
10793
func (v *InitJSON) Output(messageCode InitMessageCode, params ...any) {
10894
// don't add empty messages to json output
10995
preppedMessage := v.PrepareMessage(messageCode, params...)

0 commit comments

Comments
 (0)