@@ -40,11 +40,24 @@ function testcase() {
4040 cd " ${tmp} "
4141}
4242
43+ function helm_testcase() {
44+ echo " testcase: ${1} "
45+ tmp=$( mktemp -d " /tmp/e2e.${1} .XXXXXXXX" )
46+ cp -r " ${REPO} " /example-configs " ${tmp} "
47+ cd " ${tmp} "
48+ git clone -q https://github.com/bitnami/charts.git
49+ }
50+
4351function fail() {
4452 echo " FAIL: " " $@ "
4553 exit 1
4654}
4755
56+ function assert_contains_string() {
57+ content=" $( < " $1 " ) "
58+ grep -q " $2 " " $1 " || fail " String $2 not contained in: ${content} "
59+ }
60+
4861function assert_empty_list() {
4962 content=" $( < " $1 " ) "
5063 [[ ${content} = " ${EMPTY_OUTPUT} " ]] || fail " Not empty list: ${content} "
@@ -118,6 +131,40 @@ assert_dir_exists payments-dev
118131assert_dir_exists payments-prod
119132grep -q allowPrivilegeEscalation podsecuritypolicy_psp.yaml
120133
134+ helm_testcase " node_helm_template_command_line_args"
135+ node " ${DIST} " /helm_template_run.js -i /dev/null -d name=my-chart -d chart_path=charts/bitnami/redis/ > out.yaml
136+ assert_contains_string out.yaml " my-chart"
137+
138+ helm_testcase " node_helm_template_function_config_args"
139+ cat > fc.yaml << EOF
140+ apiVersion: v1
141+ kind: ConfigMap
142+ metadata:
143+ name: my-config
144+ annotations:
145+ config.k8s.io/function: |
146+ container:
147+ image: gcr.io/kpt-functions/helm-template
148+ config.kubernetes.io/local-config: "true"
149+ data:
150+ name: my-chart
151+ chart_path: charts/bitnami/redis
152+ EOF
153+ node " ${DIST} " /helm_template_run.js -i /dev/null -f fc.yaml > out.yaml
154+ assert_contains_string out.yaml " my-chart"
155+
156+ helm_testcase " node_helm_template_undefined_args"
157+ node " ${DIST} " /helm_template_run.js -i /dev/null 2> err.txt || true
158+ assert_contains_string err.txt " Error: functionConfig expected, instead undefined"
159+
160+ helm_testcase " node_helm_template_transform_funct"
161+ node " ${DIST} " /read_yaml_run.js -i /dev/null -d source_dir=" $( pwd) " /example-configs |
162+ node " ${DIST} " /helm_template_run.js -i /dev/null -d name=my-chart -d chart_path=charts/bitnami/redis/ |
163+ node " ${DIST} " /write_yaml_run.js -o /dev/null -d sink_dir=" $( pwd) " /example-configs -d overwrite=true
164+ assert_dir_exists example-configs/shipping-dev
165+ assert_dir_exists example-configs/default
166+ grep -q " name: my-chart-redis-master" example-configs/default/service_my-chart-redis-master.yaml
167+
121168# ###########################
122169# Docker Tests
123170# ###########################
0 commit comments