-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log the human readable plan to debug log #227
Conversation
This change is part of the following stack: Change managed by git-spice. |
pkg/tfsandbox/plan.go
Outdated
@@ -73,5 +73,11 @@ func (t *Tofu) planWithOptions(ctx context.Context, logger Logger, refreshOnly b | |||
return nil, fmt.Errorf("error running show plan: %w", err) | |||
} | |||
|
|||
humanPlan, err := t.tf.ShowPlanFileRaw(ctx, planFile, tfexec.JSONNumber(true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably run in parallel with ShowPlanFile right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
a758987
to
69ee467
Compare
pkg/tfsandbox/plan.go
Outdated
plan, err := t.tf.ShowPlanFile(ctx, planFile, tfexec.JSONNumber(true)) | ||
if err != nil { | ||
return nil, fmt.Errorf("error running show plan: %w", err) | ||
var wg sync.WaitGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go makes this kind of parallelism really awkward. You have a lot of machinery in use here, it's probably fine but heavy. A bit of Go golf, you really need only one WaitGroup or one chan, and can do a fork-join pattern. Can also leave micro-optimization for later with a comment, sorry for picking here.
func fx() (int, error) {
return 2, fmt.Errorf("f-failed")
}
func gx() (int, error) {
return 1, fmt.Errorf("g-failed")
}
func par() (int, error) {
var (
fr int
ferr error
fch chan bool = make(chan bool)
)
// fork
go func() {
defer close(fch)
fr, ferr = fx()
}()
gr, gerr := gx()
// join
<-fch
err := errors.Join(ferr, gerr)
if err != nil {
return 0, err
}
return fr + gr, nil
}
69ee467
to
1d7bc62
Compare
1d7bc62
to
64432ce
Compare
This PR has been shipped in release v0.0.6. |
Follow up to #222 to add the human readable plan to the debug log
output.
fixes #216