@@ -133,40 +133,6 @@ assert_dir_exists payments-dev
133133assert_dir_exists payments-prod
134134grep -q allowPrivilegeEscalation podsecuritypolicy_psp.yaml
135135
136- helm_testcase " node_helm_template_command_line_args"
137- node " ${DIST} " /helm_template_run.js -i /dev/null -d name=my-chart -d chart_path=charts/bitnami/redis/ > out.yaml
138- assert_contains_string out.yaml " my-chart"
139-
140- helm_testcase " node_helm_template_function_config_args"
141- cat > fc.yaml << EOF
142- apiVersion: v1
143- kind: ConfigMap
144- metadata:
145- name: my-config
146- annotations:
147- config.k8s.io/function: |
148- container:
149- image: gcr.io/kpt-functions/helm-template
150- config.kubernetes.io/local-config: "true"
151- data:
152- name: my-chart
153- chart_path: charts/bitnami/redis
154- EOF
155- node " ${DIST} " /helm_template_run.js -i /dev/null -f fc.yaml > out.yaml
156- assert_contains_string out.yaml " my-chart"
157-
158- helm_testcase " node_helm_template_undefined_args"
159- node " ${DIST} " /helm_template_run.js -i /dev/null 2> err.txt || true
160- assert_contains_string err.txt " Error: functionConfig expected, instead undefined"
161-
162- helm_testcase " node_helm_template_transform_funct"
163- node " ${DIST} " /read_yaml_run.js -i /dev/null -d source_dir=" $( pwd) " /example-configs |
164- node " ${DIST} " /helm_template_run.js -i /dev/null -d name=my-chart -d chart_path=charts/bitnami/redis/ |
165- node " ${DIST} " /write_yaml_run.js -o /dev/null -d sink_dir=" $( pwd) " /example-configs -d overwrite=true
166- assert_dir_exists example-configs/shipping-dev
167- assert_dir_exists example-configs/default
168- grep -q " name: my-chart-redis-master" example-configs/default/service_my-chart-redis-master.yaml
169-
170136# ###########################
171137# Docker Tests
172138# ###########################
@@ -211,14 +177,52 @@ assert_dir_exists payments-dev
211177assert_dir_exists payments-prod
212178grep -q allowPrivilegeEscalation podsecuritypolicy_psp.yaml
213179
180+ helm_testcase " docker_helm_template_undefined_args"
181+ docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null 2> err.txt || true
182+ assert_contains_string err.txt " Error: functionConfig expected, instead undefined"
183+
184+ helm_testcase " docker_helm_template_empty_fc"
185+ cat > fc.yaml << EOF
186+ apiVersion: v1
187+ kind: ConfigMap
188+ metadata:
189+ name: empty-config
190+ annotations:
191+ config.k8s.io/function: |
192+ container:
193+ image: gcr.io/kpt-functions/helm-template
194+ config.kubernetes.io/local-config: "true"
195+ data:
196+ EOF
197+ docker run -u " $( id -u) " -v " $( pwd) " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -f /source/fc.yaml 2> err.txt || true
198+ assert_contains_string err.txt " Error: functionConfig expected to contain data, instead empty"
199+
200+ helm_testcase " docker_helm_template_invalid_fc"
201+ cat > fc.yaml << EOF
202+ apiVersion: v1
203+ kind: ConfigMap
204+ metadata:
205+ name: invalid-config
206+ annotations:
207+ config.k8s.io/function: |
208+ container:
209+ image: gcr.io/kpt-functions/helm-template
210+ config.kubernetes.io/local-config: "true"
211+ data:
212+ name: invalid-fc
213+ chart_path: /path/to/helm/chart
214+ EOF
215+ docker run -u " $( id -u) " -v " $( pwd) " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -f /source/fc.yaml > out.yaml || true
216+ assert_contains_string out.yaml " ${HELM_ERROR_SNIPPET} "
217+
218+ helm_testcase " docker_helm_template_too_few_args"
219+ docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -d name=too-few-args > out.yaml || true
220+ assert_contains_string out.yaml " ${HELM_ERROR_SNIPPET} "
221+
214222helm_testcase " docker_helm_template_expected_args"
215223docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -d name=expected-args -d chart_path=/source/redis > out.yaml
216224assert_contains_string out.yaml " expected-args"
217225
218- helm_testcase " docker_helm_template_error_too_few_args"
219- docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -d name=too-few-args 2> err.txt || true
220- assert_contains_string err.txt " ${HELM_ERROR_SNIPPET} "
221-
222226helm_testcase " docker_helm_template_extra_args"
223227cat > fc.yaml << EOF
224228apiVersion: v1
0 commit comments