v1alpha1

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

+kubebuilder:object:generate=true +groupName=infra.contrib.fluxcd.io

Package v1alpha1 contains API Schema definitions for the infra v1alpha1 API group +kubebuilder:object:generate=true +groupName=infra.contrib.fluxcd.io

Index

Constants

View Source
const (
	HealthCheckTypeTCP     = "tcp"
	HealthCheckTypeHttpGet = "http"
)
View Source
const (
	// RunnerTLSSecretName is the name of the secret containing a TLS cert that will be written to
	// the namespace in which a terraform runner is created
	RunnerTLSSecretName   = "terraform-runner.tls"
	RunnerLabel           = "infra.contrib.fluxcd.io/terraform"
	GitRepositoryIndexKey = ".metadata.gitRepository"
	BucketIndexKey        = ".metadata.bucket"
)
View Source
const (
	TerraformKind             = "Terraform"
	TerraformFinalizer        = "finalizers.tf.contrib.fluxcd.io"
	MaxConditionMessageLength = 20000
	DisabledValue             = "disabled"
	ApprovePlanAutoValue      = "auto"
	ApprovePlanDisableValue   = "disable"

	// ArtifactFailedReason represents the fact that the
	// source artifact download failed.
	ArtifactFailedReason = "ArtifactFailed"

	TFExecNewFailedReason      = "TFExecNewFailed"
	TFExecInitFailedReason     = "TFExecInitFailed"
	VarsGenerationFailedReason = "VarsGenerationFailed"
	DriftDetectionFailedReason = "DriftDetectionFailed"
	DriftDetectedReason        = "DriftDetected"
	NoDriftReason              = "NoDrift"
	TFExecPlanFailedReason     = "TFExecPlanFailed"
	TFExecApplyFailedReason    = "TFExecApplyFailed"
	TFExecOutputFailedReason   = "TFExecOutputFailed"
	OutputsWritingFailedReason = "OutputsWritingFailed"
	HealthChecksFailedReason   = "HealthChecksFailed"
	TFExecApplySucceedReason   = "TerraformAppliedSucceed"
)

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "infra.contrib.fluxcd.io", Version: "v1alpha1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

func SetTerraformReadiness

func SetTerraformReadiness(terraform *Terraform, status metav1.ConditionStatus, reason, message string, revision string)

SetTerraformReadiness sets the ReadyCondition, ObservedGeneration, and LastAttemptedRevision, on the Terraform.

Types

type BackendConfigSpec

type BackendConfigSpec struct {

	// Disable is to completely disable the backend configuration.
	// +optional
	Disable bool `json:"disable"`

	// +optional
	SecretSuffix string `json:"secretSuffix"`

	// +optional
	InClusterConfig bool `json:"inClusterConfig"`

	// +optional
	ConfigPath string `json:"configPath,omitempty"`

	// +optional
	Labels map[string]string `json:"labels,omitempty"`
}

BackendConfigSpec is for specifying configuration for Terraform's Kubernetes backend

func (*BackendConfigSpec) DeepCopy

func (in *BackendConfigSpec) DeepCopy() *BackendConfigSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendConfigSpec.

func (*BackendConfigSpec) DeepCopyInto

func (in *BackendConfigSpec) DeepCopyInto(out *BackendConfigSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type CrossNamespaceSourceReference

type CrossNamespaceSourceReference struct {
	// API version of the referent.
	// +optional
	APIVersion string `json:"apiVersion,omitempty"`

	// Kind of the referent.
	// +kubebuilder:validation:Enum=GitRepository;Bucket
	// +required
	Kind string `json:"kind"`

	// Name of the referent.
	// +required
	Name string `json:"name"`

	// Namespace of the referent, defaults to the namespace of the Kubernetes resource object that contains the reference.
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

CrossNamespaceSourceReference contains enough information to let you locate the typed Kubernetes resource object at cluster level.

func (*CrossNamespaceSourceReference) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CrossNamespaceSourceReference.

func (*CrossNamespaceSourceReference) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*CrossNamespaceSourceReference) String

type HealthCheck

type HealthCheck struct {
	// Name of the health check.
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	// +required
	Name string `json:"name"`

	// Type of the health check, valid values are ('tcp', 'http').
	// If tcp is specified, address is required.
	// If http is specified, url is required.
	// +kubebuilder:validation:Enum=tcp;http
	// +required
	Type string `json:"type"`

	// URL to perform http health check on. Required when http type is specified.
	// Go template can be used to reference values from the terraform output
	// (e.g. https://example.org, {{.output_url}}).
	// +optional
	URL string `json:"url,omitempty"`

	// Address to perform tcp health check on. Required when tcp type is specified.
	// Go template can be used to reference values from the terraform output
	// (e.g. 127.0.0.1:8080, {{.address}}:{{.port}}).
	// +optional
	Address string `json:"address,omitempty"`

	// The timeout period at which the connection should timeout if unable to
	// complete the request.
	// When not specified, default 20s timeout is used.
	// +kubebuilder:default="20s"
	// +optional
	Timeout *metav1.Duration `json:"timeout,omitempty"`
}

HealthCheck contains configuration needed to perform a health check after terraform is applied.

func (*HealthCheck) DeepCopy

func (in *HealthCheck) DeepCopy() *HealthCheck

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HealthCheck.

func (*HealthCheck) DeepCopyInto

func (in *HealthCheck) DeepCopyInto(out *HealthCheck)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (HealthCheck) GetTimeout

func (in HealthCheck) GetTimeout() time.Duration

type PlanStatus

type PlanStatus struct {
	// +optional
	LastApplied string `json:"lastApplied,omitempty"`

	// +optional
	Pending string `json:"pending,omitempty"`

	// +optional
	IsDestroyPlan bool `json:"isDestroyPlan,omitempty"`

	// +optional
	IsDriftDetectionPlan bool `json:"isDriftDetectionPlan,omitempty"`
}

func (*PlanStatus) DeepCopy

func (in *PlanStatus) DeepCopy() *PlanStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlanStatus.

func (*PlanStatus) DeepCopyInto

func (in *PlanStatus) DeepCopyInto(out *PlanStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Terraform

type Terraform struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   TerraformSpec   `json:"spec,omitempty"`
	Status TerraformStatus `json:"status,omitempty"`
}

Terraform is the Schema for the terraforms API

func TerraformApplied

func TerraformApplied(terraform Terraform, revision string, message string, isDestroyApply bool) Terraform

func TerraformAppliedFailResetPlanAndNotReady

func TerraformAppliedFailResetPlanAndNotReady(terraform Terraform, revision, reason, message string) Terraform

func TerraformApplying

func TerraformApplying(terraform Terraform, revision string, message string) Terraform

func TerraformDriftDetected

func TerraformDriftDetected(terraform Terraform, revision, reason, message string) Terraform

func TerraformHealthCheckFailed

func TerraformHealthCheckFailed(terraform Terraform, message string) Terraform

func TerraformHealthCheckSucceeded

func TerraformHealthCheckSucceeded(terraform Terraform, message string) Terraform

func TerraformNoDrift

func TerraformNoDrift(terraform Terraform, revision, reason, message string) Terraform

func TerraformNotReady

func TerraformNotReady(terraform Terraform, revision, reason, message string) Terraform

TerraformNotReady registers a failed apply attempt of the given Terraform.

func TerraformOutputsAvailable

func TerraformOutputsAvailable(terraform Terraform, availableOutputs []string, message string) Terraform

func TerraformOutputsWritten

func TerraformOutputsWritten(terraform Terraform, revision string, message string) Terraform

func TerraformPlannedNoChanges

func TerraformPlannedNoChanges(terraform Terraform, revision string, message string) Terraform

func TerraformPlannedWithChanges

func TerraformPlannedWithChanges(terraform Terraform, revision string, message string) Terraform

func TerraformProgressing

func TerraformProgressing(terraform Terraform, message string) Terraform

TerraformProgressing resets the conditions of the given Terraform to a single ReadyCondition with status ConditionUnknown.

func (*Terraform) DeepCopy

func (in *Terraform) DeepCopy() *Terraform

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Terraform.

func (*Terraform) DeepCopyInto

func (in *Terraform) DeepCopyInto(out *Terraform)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Terraform) DeepCopyObject

func (in *Terraform) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*Terraform) FromBytes

func (in *Terraform) FromBytes(b []byte, scheme *runtime.Scheme) error

func (Terraform) GetRetryInterval

func (in Terraform) GetRetryInterval() time.Duration

GetRetryInterval returns the retry interval

func (*Terraform) GetRunnerHostname

func (in *Terraform) GetRunnerHostname(ip string) string

func (*Terraform) GetStatusConditions

func (in *Terraform) GetStatusConditions() *[]metav1.Condition

GetStatusConditions returns a pointer to the Status.Conditions slice.

func (Terraform) HasDrift

func (in Terraform) HasDrift() bool

HasDrift returns true if drift has been detected since the last successful apply

func (Terraform) ToBytes

func (in Terraform) ToBytes(scheme *runtime.Scheme) ([]byte, error)

type TerraformList

type TerraformList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Terraform `json:"items"`
}

TerraformList contains a list of Terraform

func (*TerraformList) DeepCopy

func (in *TerraformList) DeepCopy() *TerraformList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TerraformList.

func (*TerraformList) DeepCopyInto

func (in *TerraformList) DeepCopyInto(out *TerraformList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*TerraformList) DeepCopyObject

func (in *TerraformList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type TerraformSpec

type TerraformSpec struct {

	// ApprovePlan specifies name of a plan wanted to approve.
	// If its value is "auto", the controller will automatically approve every plan.
	// +optional
	ApprovePlan string `json:"approvePlan,omitempty"`

	// Destroy produces a destroy plan. Applying the plan will destroy all resources.
	// +optional
	Destroy bool `json:"destroy,omitempty"`

	// +optional
	BackendConfig *BackendConfigSpec `json:"backendConfig,omitempty"`

	// List of input variables to set for the Terraform program.
	// +optional
	Vars []Variable `json:"vars,omitempty"`

	// List of references to a Secret or a ConfigMap to generate variables for
	// Terraform resources based on its data, selectively by varsKey. Values of the later
	// Secret / ConfigMap with the samek keys will override those of the former.
	// +optional
	VarsFrom []VarsReference `json:"varsFrom,omitempty"`

	// The interval at which to reconcile the Terraform.
	// +required
	Interval metav1.Duration `json:"interval"`

	// The interval at which to retry a previously failed reconciliation.
	// When not specified, the controller uses the TerraformSpec.Interval
	// value to retry failures.
	// +optional
	RetryInterval *metav1.Duration `json:"retryInterval,omitempty"`

	// Path to the directory containing Terraform (.tf) files.
	// Defaults to 'None', which translates to the root path of the SourceRef.
	// +optional
	Path string `json:"path,omitempty"`

	// SourceRef is the reference of the source where the Terraform files are stored.
	// +required
	SourceRef CrossNamespaceSourceReference `json:"sourceRef"`

	// Suspend is to tell the controller to suspend subsequent TF executions,
	// it does not apply to already started executions. Defaults to false.
	// +optional
	Suspend bool `json:"suspend,omitempty"`

	// Force instructs the controller to unconditionally
	// re-plan and re-apply TF resources. Defaults to false.
	// +kubebuilder:default:=false
	// +optional
	Force bool `json:"force,omitempty"`

	// A list of target secrets for the outputs to be written as.
	// +optional
	WriteOutputsToSecret *WriteOutputsToSecretSpec `json:"writeOutputsToSecret,omitempty"`

	// Disable automatic drift detection. Drift detection may be resource intensive in
	// the context of a large cluster or complex Terraform statefile. Defaults to false.
	// +kubebuilder:default:=false
	// +optional
	DisableDriftDetection bool `json:"disableDriftDetection,omitempty"`

	// +optional
	CliConfigSecretRef *corev1.SecretReference `json:"cliConfigSecretRef,omitempty"`

	// List of health checks to be performed.
	// +optional
	HealthChecks []HealthCheck `json:"healthChecks,omitempty"`

	// Create destroy plan and apply it to destroy terraform resources
	// upon deletion of this object. Defaults to false.
	// +kubebuilder:default:=false
	// +optional
	DestroyResourcesOnDeletion bool `json:"destroyResourcesOnDeletion,omitempty"`

	// Name of a ServiceAccount for the runner Pod to provision Terraform resources.
	// Default to tf-runner.
	// +kubebuilder:default:=tf-runner
	// +optional
	ServiceAccountName string `json:"serviceAccountName,omitempty"`

	// Clean the runner pod up after each reconciliation cycle
	// +kubebuilder:default:=true
	// +optional
	AlwaysCleanupRunnerPod *bool `json:"alwaysCleanupRunnerPod,omitempty"`

	// Configure the termination grace period for the runner pod. Use this parameter
	// to allow the Terraform process to gracefully shutdown. Consider increasing for
	// large, complex or slow-moving Terraform managed resources.
	// +kubebuilder:default:=30
	// +optional
	RunnerTerminationGracePeriodSeconds *int64 `json:"runnerTerminationGracePeriodSeconds,omitempty"`
}

TerraformSpec defines the desired state of Terraform

func (*TerraformSpec) DeepCopy

func (in *TerraformSpec) DeepCopy() *TerraformSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TerraformSpec.

func (*TerraformSpec) DeepCopyInto

func (in *TerraformSpec) DeepCopyInto(out *TerraformSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*TerraformSpec) GetAlwaysCleanupRunnerPod

func (in *TerraformSpec) GetAlwaysCleanupRunnerPod() bool

type TerraformStatus

type TerraformStatus struct {
	meta.ReconcileRequestStatus `json:",inline"`

	// ObservedGeneration is the last reconciled generation.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// +optional
	Conditions []metav1.Condition `json:"conditions,omitempty"`

	// The last successfully applied revision.
	// The revision format for Git sources is <branch|tag>/<commit-sha>.
	// +optional
	LastAppliedRevision string `json:"lastAppliedRevision,omitempty"`

	// LastAttemptedRevision is the revision of the last reconciliation attempt.
	// +optional
	LastAttemptedRevision string `json:"lastAttemptedRevision,omitempty"`

	// LastPlannedRevision is the revision used by the last planning process.
	// The result could be either no plan change or a new plan generated.
	// +optional
	LastPlannedRevision string `json:"lastPlannedRevision,omitempty"`

	// LastDriftDetectedAt is the time when the last drift was detected
	// +optional
	LastDriftDetectedAt *metav1.Time `json:"lastDriftDetectedAt,omitempty"`

	// LastAppliedByDriftDetectionAt is the time when the last drift was detected and
	// terraform apply was performed as a result
	// +optional
	LastAppliedByDriftDetectionAt *metav1.Time `json:"lastAppliedByDriftDetectionAt,omitempty"`

	// +optional
	AvailableOutputs []string `json:"availableOutputs,omitempty"`

	// +optional
	Plan PlanStatus `json:"plan,omitempty"`
}

TerraformStatus defines the observed state of Terraform

func (*TerraformStatus) DeepCopy

func (in *TerraformStatus) DeepCopy() *TerraformStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TerraformStatus.

func (*TerraformStatus) DeepCopyInto

func (in *TerraformStatus) DeepCopyInto(out *TerraformStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Variable

type Variable struct {
	// Name is the name of the variable
	// +required
	Name string `json:"name"`

	// +optional
	Value *apiextensionsv1.JSON `json:"value,omitempty"`

	// +optional
	ValueFrom *corev1.EnvVarSource `json:"valueFrom,omitempty"`
}

func (*Variable) DeepCopy

func (in *Variable) DeepCopy() *Variable

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Variable.

func (*Variable) DeepCopyInto

func (in *Variable) DeepCopyInto(out *Variable)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type VarsReference

type VarsReference struct {
	// Kind of the values referent, valid values are ('Secret', 'ConfigMap').
	// +kubebuilder:validation:Enum=Secret;ConfigMap
	// +required
	Kind string `json:"kind"`

	// Name of the values referent. Should reside in the same namespace as the
	// referring resource.
	// +kubebuilder:validation:MinLength=1
	// +kubebuilder:validation:MaxLength=253
	// +required
	Name string `json:"name"`

	// VarsKeys is the data key where the values.yaml or a specific value can be
	// found at. Defaults to all keys.
	// +optional
	VarsKeys []string `json:"varsKeys,omitempty"`

	// Optional marks this VarsReference as optional. When set, a not found error
	// for the values reference is ignored, but any VarsKey or
	// transient error will still result in a reconciliation failure.
	// +optional
	Optional bool `json:"optional,omitempty"`
}

VarsReference contain a reference of a Secret or a ConfigMap to generate variables for Terraform resources based on its data, selectively by varsKey.

func (*VarsReference) DeepCopy

func (in *VarsReference) DeepCopy() *VarsReference

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VarsReference.

func (*VarsReference) DeepCopyInto

func (in *VarsReference) DeepCopyInto(out *VarsReference)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type WriteOutputsToSecretSpec

type WriteOutputsToSecretSpec struct {
	// Name is the name of the Secret to be written
	// +required
	Name string `json:"name"`

	// Outputs contain the selected names of outputs to be written
	// to the secret. Empty array means writing all outputs, which is default.
	// +optional
	Outputs []string `json:"outputs,omitempty"`
}

WriteOutputsToSecretSpec defines where to store outputs, and which outputs to be stored.

func (*WriteOutputsToSecretSpec) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WriteOutputsToSecretSpec.

func (*WriteOutputsToSecretSpec) DeepCopyInto

func (in *WriteOutputsToSecretSpec) DeepCopyInto(out *WriteOutputsToSecretSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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