Documentation
¶
Index ¶
- func GetSecretOrConfigMap(ctx context.Context, k8sClient client.Client, isSecret bool, ...) (metav1.Object, error)
- type LegacySubResources
- type Option
- type TFConfigurationMeta
- func (meta *TFConfigurationMeta) AssembleAndTriggerJob(ctx context.Context, k8sClient client.Client, ...) error
- func (meta *TFConfigurationMeta) CheckWhetherConfigurationChanges(ctx context.Context, k8sClient client.Client, ...) error
- func (meta *TFConfigurationMeta) GetApplyJob(ctx context.Context, k8sClient client.Client, job *batchv1.Job) error
- func (meta *TFConfigurationMeta) GetCredentials(ctx context.Context, k8sClient client.Client, providerObj *v1beta1.Provider) error
- func (meta *TFConfigurationMeta) IsTFStateGenerated(ctx context.Context) bool
- func (meta *TFConfigurationMeta) KeepLegacySubResourceMetas()
- func (meta *TFConfigurationMeta) PrepareTFVariables(configuration *v1beta2.Configuration) error
- func (meta *TFConfigurationMeta) RenderConfiguration(configuration *v1beta2.Configuration, ...) (string, backend.Backend, error)
- func (meta *TFConfigurationMeta) StoreTFConfiguration(ctx context.Context, k8sClient client.Client) error
- func (meta *TFConfigurationMeta) UpdateApplyStatus(ctx context.Context, k8sClient client.Client, state types.ConfigurationState, ...) error
- func (meta *TFConfigurationMeta) UpdateDestroyStatus(ctx context.Context, k8sClient client.Client, state types.ConfigurationState, ...) error
- func (meta *TFConfigurationMeta) UpdateTerraformJobIfNeeded(ctx context.Context, k8sClient client.Client, job batchv1.Job) error
- func (meta *TFConfigurationMeta) ValidateSecretAndConfigMap(ctx context.Context, k8sClient client.Client) error
- type TFState
- type TfStateProperty
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LegacySubResources ¶
type LegacySubResources struct { // Namespace is the namespace of the Configuration, also the namespace of the sub-resources. Namespace string ApplyJobName string DestroyJobName string ConfigurationCMName string VariableSecretName string }
LegacySubResources if user specify ControllerNamespace when re-staring controller, there are some sub-resources like Secret and ConfigMap that are in the namespace of the Configuration. We need to GC these sub-resources when Configuration is deleted.
type Option ¶
type Option func(spec v1beta2.Configuration, meta *TFConfigurationMeta)
func ControllerNamespaceOption ¶
ControllerNamespaceOption will set the controller namespace for TFConfigurationMeta
type TFConfigurationMeta ¶
type TFConfigurationMeta struct { Name string Namespace string ControllerNamespace string ConfigurationType types.ConfigurationType CompleteConfiguration string Git types.Git ConfigurationChanged bool EnvChanged bool ConfigurationCMName string ApplyJobName string DestroyJobName string Envs []v1.EnvVar ProviderReference *crossplane.Reference VariableSecretName string VariableSecretData map[string][]byte DeleteResource bool Region string Credentials map[string]string JobEnv map[string]interface{} GitCredentialsSecretReference *v1.SecretReference TerraformCredentialsSecretReference *v1.SecretReference TerraformRCConfigMapReference *v1.SecretReference TerraformCredentialsHelperConfigMapReference *v1.SecretReference Backend backend.Backend // JobNodeSelector Expose the node selector of job to the controller level JobNodeSelector map[string]string // TerraformImage is the Terraform image which can run `terraform init/plan/apply` TerraformImage string BusyboxImage string GitImage string // BackoffLimit specifies the number of retries to mark the Job as failed BackoffLimit int32 // ResourceQuota series Variables are for Setting Compute Resources required by this container ResourceQuota types.ResourceQuota LegacySubResources LegacySubResources ControllerNSSpecified bool K8sClient client.Client }
TFConfigurationMeta is all the metadata of a Configuration
func New ¶
func New(req ctrl.Request, configuration v1beta2.Configuration, k8sClient client.Client, option ...Option) *TFConfigurationMeta
New will create a new TFConfigurationMeta to process the configuration
func (*TFConfigurationMeta) AssembleAndTriggerJob ¶
func (meta *TFConfigurationMeta) AssembleAndTriggerJob(ctx context.Context, k8sClient client.Client, executionType types.TerraformExecutionType) error
func (*TFConfigurationMeta) CheckWhetherConfigurationChanges ¶
func (meta *TFConfigurationMeta) CheckWhetherConfigurationChanges(ctx context.Context, k8sClient client.Client, configurationType types.ConfigurationType) error
CheckWhetherConfigurationChanges will check whether configuration is changed
func (*TFConfigurationMeta) GetApplyJob ¶
func (*TFConfigurationMeta) GetCredentials ¶
func (meta *TFConfigurationMeta) GetCredentials(ctx context.Context, k8sClient client.Client, providerObj *v1beta1.Provider) error
GetCredentials will get credentials from secret of the Provider
func (*TFConfigurationMeta) IsTFStateGenerated ¶
func (meta *TFConfigurationMeta) IsTFStateGenerated(ctx context.Context) bool
func (*TFConfigurationMeta) KeepLegacySubResourceMetas ¶
func (meta *TFConfigurationMeta) KeepLegacySubResourceMetas()
func (*TFConfigurationMeta) PrepareTFVariables ¶
func (meta *TFConfigurationMeta) PrepareTFVariables(configuration *v1beta2.Configuration) error
func (*TFConfigurationMeta) RenderConfiguration ¶
func (meta *TFConfigurationMeta) RenderConfiguration(configuration *v1beta2.Configuration, configurationType types.ConfigurationType) (string, backend.Backend, error)
RenderConfiguration will compose the Terraform configuration with hcl/json and backend
func (*TFConfigurationMeta) StoreTFConfiguration ¶
func (meta *TFConfigurationMeta) StoreTFConfiguration(ctx context.Context, k8sClient client.Client) error
StoreTFConfiguration will store Terraform configuration to ConfigMap
func (*TFConfigurationMeta) UpdateApplyStatus ¶
func (meta *TFConfigurationMeta) UpdateApplyStatus(ctx context.Context, k8sClient client.Client, state types.ConfigurationState, message string) error
func (*TFConfigurationMeta) UpdateDestroyStatus ¶
func (meta *TFConfigurationMeta) UpdateDestroyStatus(ctx context.Context, k8sClient client.Client, state types.ConfigurationState, message string) error
func (*TFConfigurationMeta) UpdateTerraformJobIfNeeded ¶
func (meta *TFConfigurationMeta) UpdateTerraformJobIfNeeded(ctx context.Context, k8sClient client.Client, job batchv1.Job) error
UpdateTerraformJobIfNeeded will set deletion finalizer to the Terraform job if its envs are changed, which will result in deleting the job. Finally, a new Terraform job will be generated
func (*TFConfigurationMeta) ValidateSecretAndConfigMap ¶
type TFState ¶
type TFState struct {
Outputs map[string]TfStateProperty `json:"outputs"`
}
TFState is Terraform State
type TfStateProperty ¶
type TfStateProperty struct { Value interface{} `json:"value,omitempty"` Type interface{} `json:"type,omitempty"` }
TfStateProperty is the tf state property for an output
func (*TfStateProperty) ToProperty ¶
func (tp *TfStateProperty) ToProperty() (v1beta2.Property, error)
ToProperty converts TfStateProperty type to Property