terraformer

package
v0.0.0-...-133fb1b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Terraformer

type Terraformer struct {
	*operation.Operation
	Purpose              string
	Namespace            string
	ConfigName           string
	VariablesName        string
	StateName            string
	PodName              string
	JobName              string
	VariablesEnvironment []map[string]interface{}
	ConfigurationDefined bool
}

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

  • Operation is a reference to an operation object.
  • Purpose is a one-word description depicting what the Terraformer does (e.g. 'infrastructure').
  • Namespace is the namespace in which the Terraformer will act (usually the Shoot namespace).
  • 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(o *operation.Operation, purpose string) *Terraformer

New takes a Operation object <o> and a string <purpose> which describes for what the Terraformer is used, and 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 (*Terraformer) Apply

func (t *Terraformer) Apply() error

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

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 confidental information like credentials.

func (*Terraformer) Destroy

func (t *Terraformer) Destroy() error

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

func (*Terraformer) GetState

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

GetState returns the Terraform state as byte slice.

func (*Terraformer) IsStateEmpty

func (t *Terraformer) IsStateEmpty() bool

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

func (*Terraformer) SetVariablesEnvironment

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

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

Jump to

Keyboard shortcuts

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