brew install kustomize
export NS_PREFIX=chanwit
--- | |
apiVersion: source.toolkit.fluxcd.io/v1beta2 | |
kind: GitRepository | |
metadata: | |
name: podinfo-source | |
namespace: chanwit | |
spec: | |
interval: 1m0s | |
ref: | |
branch: master |
--- | |
apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 | |
kind: Kustomization | |
metadata: | |
name: podinfo | |
namespace: <your name> | |
spec: | |
interval: 1m0s | |
path: ./kustomize | |
prune: true |
package run_test | |
import ( | |
"context" | |
"sigs.k8s.io/controller-runtime/pkg/client" | |
) | |
type stateInstallDevBucketServer string | |
// mock controller-runtime client |
node { | |
} |
infrav1.Terraform{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: terraformName, | |
Namespace: "flux-system", | |
}, | |
Spec: infrav1.TerraformSpec{ | |
ApprovePlan: "auto", | |
Path: "./terraform-hello-world-example", | |
SourceRef: infrav1.CrossNamespaceSourceReference{ | |
Kind: "GitRepository", |
SPEC: This spec describes the behaviour of a Terraform resource with no backend, and `auto` approve. | |
IT should be reconciled to have available outputs. | |
GIVEN: a GitRepository | |
BY: defining a new GitRepository resource. | |
BY: creating the GitRepository resource in the cluster. | |
IT should be created successfully. | |
GIVEN: the GitRepository's reconciled status. | |
BY: setting the GitRepository's status, with the downloadable BLOB's URL, and the correct checksum. |
// TerraformSpec defines the desired state of Terraform | |
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"` | |
// +optional | |
BackendConfig *BackendConfigSpec `json:"backendConfig,omitempty"` |
$ kubebuilder create api --group infra --version v1alpha1 --kind Terraform |
$ go mod init github.com/chanwit/tf-controller | |
$ kubebuilder init --domain contrib.fluxcd.io |