Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTerraformTemplate(workspace *v1alpha1.Workspace) ([]byte, error)
- func MapToTFCRunTrigger(workspace string, specRunTriggers []*v1alpha1.RunTrigger) []*tfc.RunTrigger
- func MapToTFCVariable(specVariables []*v1alpha1.Variable) []*tfc.Variable
- func NewWorkspaceHelper(mgr manager.Manager) reconcile.Reconciler
- type TerraformCloudClient
- func (t *TerraformCloudClient) AssignWorkspaceSSHKey(workspaceID string, SSHKeyID string) (string, error)
- func (t *TerraformCloudClient) CheckNotifications(instance *appv1alpha1.Workspace) error
- func (t *TerraformCloudClient) CheckOrganization() error
- func (t *TerraformCloudClient) CheckOutputs(workspaceID string, runID string) ([]*v1alpha1.OutputStatus, error)
- func (t *TerraformCloudClient) CheckRun(runID string) (string, error)
- func (t *TerraformCloudClient) CheckRunTriggers(workspace string, specRunTriggers []*v1alpha1.RunTrigger) (bool, error)
- func (t *TerraformCloudClient) CheckSecretsMountPath() error
- func (t *TerraformCloudClient) CheckVariables(workspace string, specTFCVariables []*tfc.Variable) (bool, error)
- func (t *TerraformCloudClient) CheckWorkspace(workspace string, instance *appv1alpha1.Workspace) (*tfc.Workspace, error)
- func (t *TerraformCloudClient) CheckWorkspacebyID(workspaceID string) error
- func (t *TerraformCloudClient) CreateConfigurationVersion(workspaceID string) (*tfc.ConfigurationVersion, error)
- func (t *TerraformCloudClient) CreateTerraformRunTrigger(workspace *tfc.Workspace, runTrigger *tfc.RunTrigger) error
- func (t *TerraformCloudClient) CreateTerraformVariable(workspace *tfc.Workspace, variable *tfc.Variable) error
- func (t *TerraformCloudClient) CreateWorkspace(workspace string, instance *appv1alpha1.Workspace) (string, error)
- func (t *TerraformCloudClient) DeleteResources(workspaceID string) error
- func (t *TerraformCloudClient) DeleteRunTrigger(runTrigger *tfc.RunTrigger) error
- func (t *TerraformCloudClient) DeleteRuns(workspaceID string) error
- func (t *TerraformCloudClient) DeleteVariable(variable *tfc.Variable) error
- func (t *TerraformCloudClient) DeleteWorkspace(workspaceID string) error
- func (t *TerraformCloudClient) GetClient(tfEndpoint string) error
- func (t *TerraformCloudClient) GetOutputsFromState(stateDownloadURL string) ([]*v1alpha1.OutputStatus, error)
- func (t *TerraformCloudClient) GetSSHKeyByNameOrID(SSHKeyID string) (string, error)
- func (t *TerraformCloudClient) GetStateVersionDownloadURL(workspaceID string) (string, error)
- func (t *TerraformCloudClient) SetTerraformVersion(workspace, terraformVersion string) error
- func (t *TerraformCloudClient) UnassignWorkspaceSSHKey(workspaceID string) (string, error)
- func (t *TerraformCloudClient) UpdateTerraformVariables(variables []*tfc.Variable) error
- func (t *TerraformCloudClient) UploadConfigurationFile(uploadURL string) error
- type WorkspaceHelper
- func (r *WorkspaceHelper) GetConfigMapForVariable(namespace string, variable *v1alpha1.Variable) error
- func (r *WorkspaceHelper) GetSecretData(namespace string, name string) (map[string][]byte, error)
- func (r *WorkspaceHelper) GetSecretForVariable(namespace string, variable *v1alpha1.Variable) error
- func (r *WorkspaceHelper) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
- func (r *WorkspaceHelper) UpsertSecretOutputs(w *v1alpha1.Workspace, outputs []*v1alpha1.OutputStatus) error
- func (r *WorkspaceHelper) UpsertTerraformConfig(w *v1alpha1.Workspace, template []byte) (bool, error)
Constants ¶
const ( // TerraformConfigMap names the Terraform template ConfigMap TerraformConfigMap = "terraform" // TerraformOperator is for labelling TerraformOperator = "terraform-k8s" )
const (
// PageSize is page size for TFC API
PageSize = 500
)
Variables ¶
var ( // AutoApply run to workspace AutoApply = true AgentPageSize = 100 )
Functions ¶
func CreateTerraformTemplate ¶
CreateTerraformTemplate creates a template for the Terraform configuration
func MapToTFCRunTrigger ¶ added in v1.1.0
func MapToTFCRunTrigger(workspace string, specRunTriggers []*v1alpha1.RunTrigger) []*tfc.RunTrigger
MapToTFCRunTrigger changes controller spec to a TFC RunTrigger
func MapToTFCVariable ¶
MapToTFCVariable changes the controller spec to a TFC Variable
func NewWorkspaceHelper ¶
func NewWorkspaceHelper(mgr manager.Manager) reconcile.Reconciler
Types ¶
type TerraformCloudClient ¶
TerraformCloudClient has a TFC Client and organization
func (*TerraformCloudClient) AssignWorkspaceSSHKey ¶
func (t *TerraformCloudClient) AssignWorkspaceSSHKey(workspaceID string, SSHKeyID string) (string, error)
AssignWorkspaceSSHKey to Terraform Cloud Workspace
func (*TerraformCloudClient) CheckNotifications ¶ added in v1.1.0
func (t *TerraformCloudClient) CheckNotifications(instance *appv1alpha1.Workspace) error
Check Notification checks, and if necessary creates, the workspace's notifications
func (*TerraformCloudClient) CheckOrganization ¶
func (t *TerraformCloudClient) CheckOrganization() error
CheckOrganization looks for an organization
func (*TerraformCloudClient) CheckOutputs ¶
func (t *TerraformCloudClient) CheckOutputs(workspaceID string, runID string) ([]*v1alpha1.OutputStatus, error)
CheckOutputs retrieves outputs for a run.
func (*TerraformCloudClient) CheckRun ¶
func (t *TerraformCloudClient) CheckRun(runID string) (string, error)
CheckRun gets the run status
func (*TerraformCloudClient) CheckRunTriggers ¶ added in v1.1.0
func (t *TerraformCloudClient) CheckRunTriggers(workspace string, specRunTriggers []*v1alpha1.RunTrigger) (bool, error)
CheckRunTriggers deletes and update TFC run triggers as needed
func (*TerraformCloudClient) CheckSecretsMountPath ¶
func (t *TerraformCloudClient) CheckSecretsMountPath() error
CheckSecretsMountPath ensure the secrets mount path actually exists
func (*TerraformCloudClient) CheckVariables ¶
func (t *TerraformCloudClient) CheckVariables(workspace string, specTFCVariables []*tfc.Variable) (bool, error)
CheckVariables creates, updates, or deletes variables as needed
func (*TerraformCloudClient) CheckWorkspace ¶
func (t *TerraformCloudClient) CheckWorkspace(workspace string, instance *appv1alpha1.Workspace) (*tfc.Workspace, error)
CheckWorkspace looks for a remote tfc workspace
func (*TerraformCloudClient) CheckWorkspacebyID ¶
func (t *TerraformCloudClient) CheckWorkspacebyID(workspaceID string) error
CheckWorkspacebyID checks a workspace by ID
func (*TerraformCloudClient) CreateConfigurationVersion ¶
func (t *TerraformCloudClient) CreateConfigurationVersion(workspaceID string) (*tfc.ConfigurationVersion, error)
CreateConfigurationVersion creates a configuration version for a workspace
func (*TerraformCloudClient) CreateTerraformRunTrigger ¶ added in v1.1.0
func (t *TerraformCloudClient) CreateTerraformRunTrigger(workspace *tfc.Workspace, runTrigger *tfc.RunTrigger) error
func (*TerraformCloudClient) CreateTerraformVariable ¶
func (t *TerraformCloudClient) CreateTerraformVariable(workspace *tfc.Workspace, variable *tfc.Variable) error
CreateTerraformVariable creates a Terraform variable based on key and value
func (*TerraformCloudClient) CreateWorkspace ¶
func (t *TerraformCloudClient) CreateWorkspace(workspace string, instance *appv1alpha1.Workspace) (string, error)
CreateWorkspace creates a Terraform Cloud Workspace that auto-applies
func (*TerraformCloudClient) DeleteResources ¶
func (t *TerraformCloudClient) DeleteResources(workspaceID string) error
DeleteResources destroys the resources in a workspace
func (*TerraformCloudClient) DeleteRunTrigger ¶ added in v1.1.0
func (t *TerraformCloudClient) DeleteRunTrigger(runTrigger *tfc.RunTrigger) error
func (*TerraformCloudClient) DeleteRuns ¶
func (t *TerraformCloudClient) DeleteRuns(workspaceID string) error
DeleteRuns cancels runs that haven't been applied or planned
func (*TerraformCloudClient) DeleteVariable ¶
func (t *TerraformCloudClient) DeleteVariable(variable *tfc.Variable) error
DeleteVariable removes the variable by ID from Terraform Cloud
func (*TerraformCloudClient) DeleteWorkspace ¶
func (t *TerraformCloudClient) DeleteWorkspace(workspaceID string) error
DeleteWorkspace removes the workspace from Terraform Cloud
func (*TerraformCloudClient) GetClient ¶
func (t *TerraformCloudClient) GetClient(tfEndpoint string) error
GetClient creates the configuration for Terraform Cloud
func (*TerraformCloudClient) GetOutputsFromState ¶
func (t *TerraformCloudClient) GetOutputsFromState(stateDownloadURL string) ([]*v1alpha1.OutputStatus, error)
GetOutputsFromState gets list of outputs from state file
func (*TerraformCloudClient) GetSSHKeyByNameOrID ¶
func (t *TerraformCloudClient) GetSSHKeyByNameOrID(SSHKeyID string) (string, error)
GetSSHKeyByNameOrID Lookup provided Key ID by name or ID, return ID.
func (*TerraformCloudClient) GetStateVersionDownloadURL ¶
func (t *TerraformCloudClient) GetStateVersionDownloadURL(workspaceID string) (string, error)
GetStateVersionDownloadURL retrieves download URL for state file
func (*TerraformCloudClient) SetTerraformVersion ¶
func (t *TerraformCloudClient) SetTerraformVersion(workspace, terraformVersion string) error
func (*TerraformCloudClient) UnassignWorkspaceSSHKey ¶
func (t *TerraformCloudClient) UnassignWorkspaceSSHKey(workspaceID string) (string, error)
UnassignWorkspaceSSHKey from Terraform Cloud Workspace
func (*TerraformCloudClient) UpdateTerraformVariables ¶
func (t *TerraformCloudClient) UpdateTerraformVariables(variables []*tfc.Variable) error
UpdateTerraformVariables updates a list of variable
func (*TerraformCloudClient) UploadConfigurationFile ¶
func (t *TerraformCloudClient) UploadConfigurationFile(uploadURL string) error
UploadConfigurationFile uploads the main.tf to a configuration version
type WorkspaceHelper ¶
type WorkspaceHelper struct {
// contains filtered or unexported fields
}
func (*WorkspaceHelper) GetConfigMapForVariable ¶
func (r *WorkspaceHelper) GetConfigMapForVariable(namespace string, variable *v1alpha1.Variable) error
GetConfigMapForVariable retrieves the configmap value associated with the variable
func (*WorkspaceHelper) GetSecretData ¶ added in v1.1.2
GetSecretData retrieves the data from a secret in a given namespace
func (*WorkspaceHelper) GetSecretForVariable ¶ added in v1.1.2
func (r *WorkspaceHelper) GetSecretForVariable(namespace string, variable *v1alpha1.Variable) error
GetSecretForVariable retrieves the sensitive value associated with the variable from a secret
func (*WorkspaceHelper) Reconcile ¶
func (r *WorkspaceHelper) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error)
Reconcile reads that state of the cluster for a Workspace object and makes changes based on the state read and what is in the Workspace.Spec Note: The Controller will requeue the Request to be processed again if the returned error is non-nil or Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
func (*WorkspaceHelper) UpsertSecretOutputs ¶
func (r *WorkspaceHelper) UpsertSecretOutputs(w *v1alpha1.Workspace, outputs []*v1alpha1.OutputStatus) error
UpsertSecretOutputs creates a Secret for the outputs
func (*WorkspaceHelper) UpsertTerraformConfig ¶
func (r *WorkspaceHelper) UpsertTerraformConfig(w *v1alpha1.Workspace, template []byte) (bool, error)
UpsertTerraformConfig creates a ConfigMap for the Terraform template if it doesn't exist already