Skip to content

Commit

Permalink
feat: add option to set stdout/err
Browse files Browse the repository at this point in the history
  • Loading branch information
wjf3121 committed Aug 8, 2024
1 parent e51918a commit c20ef62
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit c20ef62

Please sign in to comment.