Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions api/v1alpha1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ type WorkspaceSpec struct {
// Specifies the agent pool name we wish to use.
// +optional
AgentPoolName string `json:"agentPoolName,omitempty"`
// Specifies if the auto apply feature for the workspace is disabled or enabled
// +optional
DisableAutoApply bool `json:"disableAutoApply"`
}

// WorkspaceStatus defines the observed state of Workspace
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/app.terraform.io_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ spec:
agentPoolName:
description: Specifies the agent pool name we wish to use.
type: string
disableAutoApply:
description: Specifies if auto apply will be disabled or enabled
type: boolean
module:
description: Module source and version to use
nullable: true
Expand Down
11 changes: 8 additions & 3 deletions workspacehelper/tfc_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
)

var (
// AutoApply run to workspace
AutoApply = true
AgentPageSize = 100
)

Expand Down Expand Up @@ -217,8 +215,15 @@ func (t *TerraformCloudClient) CreateWorkspace(workspace string, instance *appv1
tfVersion = instance.Spec.TerraformVersion
}

var autoApply bool
if instance.Spec.DisableAutoApply {
autoApply = false
} else {
autoApply = true
}

options := tfc.WorkspaceCreateOptions{
AutoApply: &AutoApply,
AutoApply: &autoApply,
Name: &workspace,
TerraformVersion: &tfVersion,
}
Expand Down