Documentation ¶
Index ¶
- Constants
- func CreateOrUpdateConfigurationConfigMap(ctx context.Context, c client.Client, namespace, name, main, variables string, ...) (*corev1.ConfigMap, error)
- func CreateOrUpdateTFVarsSecret(ctx context.Context, c client.Client, namespace, name string, tfvars []byte, ...) (*corev1.Secret, error)
- func CreateState(ctx context.Context, c client.Client, namespace, name string, ...) error
- func IsVariablesNotFoundError(err error) bool
- type CreateOrUpdateState
- type Factory
- type Initializer
- type InitializerConfig
- type RawState
- type StateConfigMapInitializer
- type StateConfigMapInitializerFunc
- type TerraformFiles
- type Terraformer
Constants ¶
const ( // MainKey is the key of the main.tf file inside the configuration ConfigMap. MainKey = "main.tf" // VariablesKey is the key of the variables.tf file inside the configuration ConfigMap. VariablesKey = "variables.tf" // TFVarsKey is the key of the terraform.tfvars file inside the variables Secret. TFVarsKey = "terraform.tfvars" // StateKey is the key of the terraform.tfstate file inside the state ConfigMap. StateKey = "terraform.tfstate" )
const ( // LabelKeyName is a key for label on a Terraformer Pod indicating the Terraformer name. LabelKeyName = "terraformer.gardener.cloud/name" // LabelKeyPurpose is a key for label on a Terraformer Pod indicating the Terraformer purpose. LabelKeyPurpose = "terraformer.gardener.cloud/purpose" )
const ( // CommandApply is a constant for the "apply" command. CommandApply = "apply" // CommandDestroy is a constant for the "destroy" command. CommandDestroy = "destroy" )
const ( // ConfigSuffix is the suffix used for the ConfigMap which stores the Terraform configuration and variables declaration. ConfigSuffix = ".tf-config" // VariablesSuffix is the suffix used for the Secret which stores the Terraform variables definition. VariablesSuffix = ".tf-vars" // StateSuffix is the suffix used for the ConfigMap which stores the Terraform state. StateSuffix = ".tf-state" // Base64Encoding denotes base64 encoding for the RawState.Data Base64Encoding = "base64" // NoneEncoding denotes none encoding for the RawState.Data NoneEncoding = "none" )
const (
// TerraformerFinalizer is the finalizer key set by the terraformer on the configmaps and secrets
TerraformerFinalizer = "gardener.cloud/terraformer"
)
Variables ¶
This section is empty.
Functions ¶
func CreateOrUpdateConfigurationConfigMap ¶
func CreateOrUpdateConfigurationConfigMap(ctx context.Context, c client.Client, namespace, name, main, variables string, ownerRef *metav1.OwnerReference) (*corev1.ConfigMap, error)
CreateOrUpdateConfigurationConfigMap creates or updates the Terraform configuration ConfigMap with the given main and variables content.
func CreateOrUpdateTFVarsSecret ¶
func CreateOrUpdateTFVarsSecret(ctx context.Context, c client.Client, namespace, name string, tfvars []byte, ownerRef *metav1.OwnerReference) (*corev1.Secret, error)
CreateOrUpdateTFVarsSecret creates or updates the Terraformer variables Secret with the given tfvars.
func CreateState ¶ added in v1.4.0
func CreateState(ctx context.Context, c client.Client, namespace, name string, ownerRef *metav1.OwnerReference) error
CreateState create terraform state config map and use empty state. It does not create or update state ConfigMap if already exists,
func IsVariablesNotFoundError ¶
IsVariablesNotFoundError returns true if the error indicates that not all variables have been found.
Types ¶
type CreateOrUpdateState ¶ added in v1.4.0
type CreateOrUpdateState struct {
State *string
}
CreateOrUpdateState implements StateConfigMapInitializer. It use it field state for creating or updating the state ConfigMap
func (CreateOrUpdateState) Initialize ¶ added in v1.4.0
func (cus CreateOrUpdateState) Initialize(ctx context.Context, c client.Client, namespace, name string, ownerRef *metav1.OwnerReference) error
Initialize implements StateConfigMapInitializer
type Factory ¶
type Factory interface { NewForConfig(logger logr.Logger, config *rest.Config, purpose, namespace, name, image string) (Terraformer, error) New(logger logr.Logger, client client.Client, coreV1Client corev1client.CoreV1Interface, purpose, namespace, name, image string) Terraformer DefaultInitializer(c client.Client, main, variables string, tfVars []byte, stateInitializer StateConfigMapInitializer) Initializer }
Factory is a factory that can produce Terraformer and Initializer.
type Initializer ¶
type Initializer interface {
Initialize(ctx context.Context, config *InitializerConfig, ownerRef *metav1.OwnerReference) error
}
Initializer can initialize a Terraformer.
func DefaultInitializer ¶
func DefaultInitializer(c client.Client, main, variables string, tfvars []byte, stateInitializer StateConfigMapInitializer) Initializer
DefaultInitializer is an Initializer that initializes the configuration, variables and state resources based on the given main, variables and tfvars content and on the given InitializerConfig.
type InitializerConfig ¶
type InitializerConfig struct { // Namespace is the namespace where all the resources required for the Terraformer shall be // deployed. Namespace string // ConfigurationName is the desired name of the configuration ConfigMap. ConfigurationName string // VariablesName is the desired name of the variables Secret. VariablesName string // StateName is the desired name of the state ConfigMap. StateName string // InitializeState specifies whether an empty state should be initialized or not. InitializeState bool }
InitializerConfig is the configuration about the location and naming of the resources the Terraformer expects.
type RawState ¶
RawState represent the terraformer state's raw data
func UnmarshalRawState ¶
UnmarshalRawState transform passed rawState to RawState struct. It tries to decode the state
type StateConfigMapInitializer ¶ added in v1.4.0
type StateConfigMapInitializer interface {
Initialize(ctx context.Context, c client.Client, namespace, name string, ownerRef *metav1.OwnerReference) error
}
StateConfigMapInitializer initialize terraformer state ConfigMap
type StateConfigMapInitializerFunc ¶ added in v1.4.0
type StateConfigMapInitializerFunc func(ctx context.Context, c client.Client, namespace, name string, ownerRef *metav1.OwnerReference) error
StateConfigMapInitializerFunc implements StateConfigMapInitializer
func (StateConfigMapInitializerFunc) Initialize ¶ added in v1.4.0
func (f StateConfigMapInitializerFunc) Initialize(ctx context.Context, c client.Client, namespace, name string, ownerRef *metav1.OwnerReference) error
Initialize implements StateConfigMapInitializer
type TerraformFiles ¶ added in v1.8.0
TerraformFiles contains all files necessary for initializing a Terraformer.
func ExtractTerraformFiles ¶ added in v1.8.0
func ExtractTerraformFiles(release *chartrenderer.RenderedChart) (*TerraformFiles, error)
ExtractTerraformFiles extracts TerraformFiles from the given RenderedChart.
It errors if a file is not contained in the chart.
type Terraformer ¶
type Terraformer interface { // UseV1 configures if it should use flags compatible with terraformer@v1. // If not specified explicitly, flags compatible with terraformer@v2 will be used. // // Deprecated: terraformer@v1 is deprecated. Consider switching to terraformer@v2 instead. UseV1(bool) Terraformer // UseV2 configures if it should use flags compatible with terraformer@v2. // TODO (acumino): The func is preserved for backwards compatibility. Remove in a future version. // // Deprecated: terraformer@v2 is the default version, hence it is no longer needed to specify it explicitly. UseV2(bool) Terraformer SetLogLevel(string) Terraformer SetEnvVars(envVars ...corev1.EnvVar) Terraformer SetTerminationGracePeriodSeconds(int64) Terraformer SetDeadlineCleaning(time.Duration) Terraformer SetDeadlinePod(time.Duration) Terraformer SetDeadlinePodCreation(time.Duration) Terraformer SetOwnerRef(*metav1.OwnerReference) Terraformer InitializeWith(ctx context.Context, initializer Initializer) Terraformer Apply(ctx context.Context) error Destroy(ctx context.Context) error GetRawState(ctx context.Context) (*RawState, error) GetState(ctx context.Context) ([]byte, error) IsStateEmpty(ctx context.Context) bool CleanupConfiguration(ctx context.Context) error RemoveTerraformerFinalizerFromConfig(ctx context.Context) error GetStateOutputVariables(ctx context.Context, variables ...string) (map[string]string, error) ConfigExists(ctx context.Context) (bool, error) NumberOfResources(ctx context.Context) (int, error) EnsureCleanedUp(ctx context.Context) error WaitForCleanEnvironment(ctx context.Context) error }
Terraformer is the Terraformer interface.
func New ¶
func New( logger logr.Logger, c client.Client, coreV1Client corev1client.CoreV1Interface, purpose, namespace, name, image string, ) Terraformer
New takes a <logger>, a <k8sClient>, a string <purpose>, which describes for what the Terraformer is used, a <name>, a <namespace> in which the Terraformer will run, and the <image> name for the to-be-used Docker image. It returns a Terraformer interface with initialized values for the namespace and the names which will be used for all the stored resources like ConfigMaps/Secrets.
func NewForConfig ¶
func NewForConfig( logger logr.Logger, config *rest.Config, purpose, namespace, name, image string, ) ( Terraformer, error, )
NewForConfig creates a new Terraformer and its dependencies from the given configuration.