terraformer

package
v0.0.0-...-32fc51b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2018 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsVariablesNotFoundError

func IsVariablesNotFoundError(err error) bool

IsVariablesNotFoundError returns true if the error indicates that not all variables have been found.

Types

type Terraformer

type Terraformer struct {
	// contains filtered or unexported fields
}

Terraformer is a struct containing configuration parameters for the Terraform script it acts on.

  • purpose is a one-word description depicting what the Terraformer does (e.g. 'infrastructure').
  • namespace is the namespace in which the Terraformer will act.
  • image is the Docker image name of the Terraformer image.
  • configName is the name of the ConfigMap containing the main Terraform file ('main.tf').
  • variablesName is the name of the Secret containing the Terraform variables ('terraform.tfvars').
  • stateName is the name of the ConfigMap containing the Terraform state ('terraform.tfstate').
  • podName is the name of the Pod which will validate the Terraform file.
  • jobName is the name of the Job which will execute the Terraform file.
  • variablesEnvironment is a map of environment variables which will be injected in the resulting Terraform job/pod. These variables should contain Terraform variables (i.e., must be prefixed with TF_VAR_).
  • configurationDefined indicates whether the required configuration ConfigMaps/Secrets have been successfully defined.

func New

func New(logger *logrus.Entry, k8sClient kubernetes.Client, purpose, name, namespace string, imageVector imagevector.ImageVector) (*Terraformer, error)

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 struct with initialized values for the namespace and the names which will be used for all the stored resources like ConfigMaps/Secrets.

func NewFromOperation

func NewFromOperation(o *operation.Operation, purpose string) (*Terraformer, error)

NewFromOperation takes an <o> operation object and initializes the Terraformer, and a string <purpose> and returns an initialized Terraformer.

func (*Terraformer) Apply

func (t *Terraformer) Apply() error

Apply executes the Terraform Job by running the 'terraform apply' command.

func (*Terraformer) CleanupJob

func (t *Terraformer) CleanupJob(jobPodList *corev1.PodList) error

CleanupJob deletes the Terraform Job and all belonging Pods from the Garden cluster.

func (*Terraformer) ConfigExists

func (t *Terraformer) ConfigExists() (bool, error)

ConfigExists returns true if all three Terraform configuration secrets/configmaps exist, and false otherwise.

func (*Terraformer) DefineConfig

func (t *Terraformer) DefineConfig(chartName string, values map[string]interface{}) *Terraformer

DefineConfig creates a ConfigMap for the tf state (if it does not exist, otherwise it won't update it), as well as a ConfigMap for the tf configuration (if it does not exist, otherwise it will update it). The tfvars are stored in a Secret as the contain confidential information like credentials.

func (*Terraformer) Destroy

func (t *Terraformer) Destroy() error

Destroy executes the Terraform Job by running the 'terraform destroy' command.

func (*Terraformer) EnsureCleanedUp

func (t *Terraformer) EnsureCleanedUp() error

EnsureCleanedUp deletes the job, pods, and waits until everything has been cleaned up.

func (*Terraformer) GetState

func (t *Terraformer) GetState() ([]byte, error)

GetState returns the Terraform state as byte slice.

func (*Terraformer) GetStateOutputVariables

func (t *Terraformer) GetStateOutputVariables(variables ...string) (map[string]string, error)

GetStateOutputVariables returns the given <variable> from the given Terraform <stateData>. In case the variable was not found, an error is returned.

func (*Terraformer) IsStateEmpty

func (t *Terraformer) IsStateEmpty() bool

IsStateEmpty returns true if the Terraform state is empty, and false otherwise.

func (*Terraformer) ListJobPods

func (t *Terraformer) ListJobPods() (*corev1.PodList, error)

ListJobPods lists all pods which have a label 'job-name' whose value is equal to the Terraformer job name.

func (*Terraformer) SetImage

func (t *Terraformer) SetImage(image string) *Terraformer

SetImage sets the provided <image> on the Terraformer object.

func (*Terraformer) SetVariablesEnvironment

func (t *Terraformer) SetVariablesEnvironment(tfvarsEnvironment []map[string]interface{}) *Terraformer

SetVariablesEnvironment sets the provided <tfvarsEnvironment> on the Terraformer object.

func (*Terraformer) WaitForCleanEnvironment

func (t *Terraformer) WaitForCleanEnvironment() error

WaitForCleanEnvironment waits until no Terraform Job and Pod(s) exist for the current instance of the Terraformer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL