Skip to content

Commit

Permalink
Update examples to cover a few phases for more throughout testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mumoshu committed Sep 14, 2020
1 parent c9f22ff commit 6e80f76
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 87 deletions.
7 changes: 7 additions & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/testout
/helmfile-*.yaml
/*.log
/USE
/temp.values-*.yaml
/*.tf
/terraform.tfstate*
43 changes: 43 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
TF ?= terraform-v0.12.29
TEST_OUT_DIR ?= testout/$(shell cat USE | tr -d '\n' || echo current)
TF_LOG ?= TRACE

.PHONY: dev
dev:
rm tf.log tf.*.log || true
rm -rf ./tf.*.pprof || true
make testdata/01-bootstrap init plan apply
make testdata/02-more-resources plan apply
make testdata/03-add-prom plan apply
make destroy

.PHONY: init
init:
cd .. ; make build
mv ../dist/darwin_amd64/terraform-provider-helmfile .terraform/plugins/darwin_amd64/terraform-provider-helmfile
$(TF) init

.PHONY: testout
testout:
mkdir -p $(TEST_OUT_DIR)

.PHONY: apply
apply: testout
TF_LOG=$(TF_LOG) TF_LOG_PATH=$(TEST_OUT_DIR)/apply.log time -l $(TF) apply -auto-approve

.PHONY: destroy
destroy: testout
TF_LOG=$(TF_LOG) TF_LOG_PATH=$(TEST_OUT_DIR)/destroy.log time -l $(TF) destroy -auto-approve

.PHONY: plan
plan: testout
TF_LOG=$(TF_LOG) TF_LOG_PATH=$(TEST_OUT_DIR)/plan.log time -l $(TF) plan

STEPS = $(wildcard testdata/*)

.PHONY: $(STEPS)
.SECONDEXPANSION:
$(STEPS):%:$$(wildcard %/*.yaml)
@echo Preparing $@
cp $@/*.{tf,yaml} .
@echo $(shell basename $@) > USE
85 changes: 0 additions & 85 deletions examples/test.tf

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
repositories:
- name: sp
url: https://stefanprodan.github.io/podinfo

releases:
- name: {{ .Values.name }}-{{ requiredEnv "FOO" }}
chart: sp/podinfo
values:
- image:
tag: foobar2abcd
- values.yaml
labels:
labelkey1: value1
labelkey2: value2
33 changes: 33 additions & 0 deletions examples/testdata/01-bootstrap/test.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
provider "helmfile" {}

resource "helmfile_release_set" "mystack" {
content = file("./helmfile.yaml")

helm_binary = "helm3"

working_directory = path.module

environment = "default"

environment_variables = {
FOO = "foo"
}

values = [
<<EOF
{"name": "myapp"}
EOF
]

selector = {
labelkey1 = "value1"
}
}

output "mystack_diff" {
value = helmfile_release_set.mystack.diff_output
}

output "mystack_apply" {
value = helmfile_release_set.mystack.apply_output
}
12 changes: 12 additions & 0 deletions examples/testdata/02-more-resources/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repositories:
- name: sp
url: https://stefanprodan.github.io/podinfo

releases:
- name: {{ .Values.name }}-{{ requiredEnv "FOO" }}
chart: sp/podinfo
values:
- values.yaml
labels:
labelkey1: value1
labelkey2: value2
136 changes: 136 additions & 0 deletions examples/testdata/02-more-resources/test.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
provider "helmfile" {}

resource "helmfile_embedding_example" "emb1" {
embedded {
path = "./helmfile.yaml"

helm_binary = "helm3"



working_directory = path.module

environment = "default"

environment_variables = {
FOO = "emb1"
}

values = [
<<EOF
{"name": "myapp"}
EOF
]

selector = {
labelkey1 = "value1"
}
}
}

resource "helmfile_release_set" "mystack" {
content = file("./helmfile.yaml")

helm_binary = "helm3"



working_directory = path.module

environment = "default"

environment_variables = {
FOO = "foo"
}

values = [
<<EOF
{"name": "myapp"}
EOF
]

selector = {
labelkey1 = "value1"
}
}

resource "helmfile_release_set" "mystack2" {
content = <<EOF
releases:
- name: myapp2
chart: sp/podinfo
values:
- image:
tag: "123"
labels:
labelkey1: value1
- name: myapp3
chart: sp/podinfo
values:
- image:
tag: "2345"
EOF

helm_binary = "helm3"

// working_directory = path.module
working_directory = "mystack2"

environment = "default"

environment_variables = {
FOO = "foo"
}

values = [
<<EOF
{"name": "myapp"}
EOF
]

selector = {
labelkey1 = "value1"
}
}

output "mystack_diff" {
value = helmfile_release_set.mystack.diff_output
}

output "mystack_apply" {
value = helmfile_release_set.mystack.apply_output
}

output "mystack2_diff" {
value = helmfile_release_set.mystack2.diff_output
}

output "mystack2_apply" {
value = helmfile_release_set.mystack2.apply_output
}

resource "helmfile_release" "myapp" {
name = "myapp"
namespace = "default"
chart = "sp/podinfo"
helm_binary = "helm3"

// working_directory = path.module
// working_directory = "myapp"
values = [
<<EOF
{ "image": {"tag": "3.1455" } }
EOF
]
}


output "myapp_diff" {
value = helmfile_release.myapp.diff_output
}

output "myapp_apply" {
value = helmfile_release.myapp.apply_output
}

16 changes: 16 additions & 0 deletions examples/testdata/03-add-prom/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
repositories:
- name: sp
url: https://stefanprodan.github.io/podinfo

releases:
- name: {{ .Values.name }}-{{ requiredEnv "FOO" }}
chart: sp/podinfo
values:
- values.yaml
labels:
labelkey1: value1
labelkey2: value2

- name: prom-operator
chart: stable/prometheus-operator
disableValidation: true
Loading

0 comments on commit 6e80f76

Please sign in to comment.