Skip to content
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

feat: add option to set stdout/err #7

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type ApplyOptions struct {
GracefulShutdownPeriod time.Duration
LockExpirationDuration time.Duration
InitOptions TFInitOptions

StdOut io.Writer
StdErr io.Writer
}

func (t *Terraform) ApplyModule(ctx context.Context, moduleOptions ModuleOptions, applyOptions ApplyOptions) error {
Expand Down Expand Up @@ -121,6 +124,9 @@ type DestroyOptions struct {
GracefulShutdownPeriod time.Duration
LockExpirationDuration time.Duration
InitOptions TFInitOptions

StdOut io.Writer
StdErr io.Writer
}

func (t *Terraform) DestroyModule(ctx context.Context, options ModuleOptions, destroyOptions DestroyOptions) error {
Expand Down Expand Up @@ -348,6 +354,9 @@ func (t *Terraform) terraformInitAndApply(ctx context.Context, workingDir, backe
return eris.Wrap(err, "failed to create Terraform exec")
}

tf.SetStdout(options.StdOut)
tf.SetStderr(options.StdErr)

err = tfInit(ctx, tf, backendPath, options.InitOptions)
if err != nil {
return eris.Wrap(err, "failed to init terraform")
Expand Down Expand Up @@ -378,6 +387,9 @@ func (t *Terraform) terraformInitAndDestroy(ctx context.Context, workingDir, bac
return eris.Wrap(err, "failed to create Terraform exec")
}

tf.SetStdout(options.StdOut)
tf.SetStderr(options.StdErr)

err = tfInit(ctx, tf, backendPath, options.InitOptions)
if err != nil {
return eris.Wrap(err, "failed to init terraform")
Expand Down