Skip to content

Commit

Permalink
Made EnableTerraformCLILogging Optional and added a description. Adde…
Browse files Browse the repository at this point in the history
…d Operation key value pair to logs.
  • Loading branch information
Rami Radaideh committed May 10, 2024
1 parent 36ee6e7 commit 503d09a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apis/v1beta1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ type WorkspaceParameters struct {
// Arguments to be included in the terraform destroy CLI command
DestroyArgs []string `json:"destroyArgs,omitempty"`

// Boolean value to indicate CLI logging of terraform execution is enabled or not
// +optional
EnableTerraformCLILogging bool `json:"enableTerraformCLILogging,omitempty"`
}

Expand Down
6 changes: 3 additions & 3 deletions internal/terraform/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ func (h Harness) Diff(ctx context.Context, o ...Option) (bool, error) {
}
case 2:
if h.EnableTerraformCLILogging {
h.Logger.Info("plan-"+string(log))
h.Logger.Info(string(log),"operation","plan")
}
return true, nil
}
Expand Down Expand Up @@ -616,7 +616,7 @@ func (h Harness) Apply(ctx context.Context, o ...Option) error {
switch cmd.ProcessState.ExitCode() {
case 0:
if h.EnableTerraformCLILogging {
h.Logger.Info("apply-"+string(log))
h.Logger.Info(string(log),"operation","apply")
}
default:
ee := &exec.ExitError{}
Expand Down Expand Up @@ -661,7 +661,7 @@ func (h Harness) Destroy(ctx context.Context, o ...Option) error {
switch cmd.ProcessState.ExitCode() {
case 0:
if h.EnableTerraformCLILogging {
h.Logger.Info("delete-"+string(log))
h.Logger.Info(string(log),"operation","delete")
}
default:
ee := &exec.ExitError{}
Expand Down
2 changes: 2 additions & 0 deletions package/crds/tf.upbound.io_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ spec:
type: string
type: array
enableTerraformCLILogging:
description: Boolean value to indicate CLI logging of terraform
execution is enabled or not
type: boolean
entrypoint:
default: ""
Expand Down

0 comments on commit 503d09a

Please sign in to comment.