@@ -28,6 +28,8 @@ metadata:
2828items: []
2929EOF
3030)
31+ HELM_ERROR_SNIPPET=" Helm template command results in error"
32+ CHARTS_SRC=" charts/bitnami"
3133
3234# ###########################
3335# Test framework
@@ -209,6 +211,47 @@ assert_dir_exists payments-dev
209211assert_dir_exists payments-prod
210212grep -q allowPrivilegeEscalation podsecuritypolicy_psp.yaml
211213
214+ helm_testcase " docker_helm_template_expected_args"
215+ docker 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
216+ assert_contains_string out.yaml " expected-args"
217+
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+
222+ helm_testcase " docker_helm_template_extra_args"
223+ cat > fc.yaml << EOF
224+ apiVersion: v1
225+ kind: ConfigMap
226+ metadata:
227+ name: my-config
228+ annotations:
229+ config.k8s.io/function: |
230+ container:
231+ image: gcr.io/kpt-functions/helm-template
232+ config.kubernetes.io/local-config: "true"
233+ data:
234+ name: extra-args
235+ chart_path: /source/charts/bitnami/redis
236+ --values: /source/charts/bitnami/redis/values-production.yaml
237+ EOF
238+ docker run -u " $( id -u) " -v " $( pwd) " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -f /source/fc.yaml > out.yaml
239+ assert_contains_string out.yaml " extra-args"
240+
241+ helm_testcase " docker_helm_template_sink"
242+ docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -d chart_path=/source/redis -d name=sink-redis |
243+ docker run -i -u " $( id -u) " -v " $( pwd) " :/sink gcr.io/kpt-functions/write-yaml:" ${TAG} " -o /dev/null -d sink_dir=/sink -d overwrite=true
244+ assert_dir_exists default
245+ assert_contains_string default/secret_sink-redis.yaml " sink-redis"
246+
247+ helm_testcase " docker_helm_template_pipeline"
248+ docker run -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -d chart_path=/source/mongodb -d name=my-mongodb |
249+ docker run -i -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -d name=my-redis -d chart_path=/source/redis |
250+ docker run -i -u " $( id -u) " -v " $( pwd) " :/sink gcr.io/kpt-functions/write-yaml:" ${TAG} " -o /dev/null -d sink_dir=/sink -d overwrite=true
251+ assert_dir_exists default
252+ assert_contains_string default/secret_my-mongodb.yaml " my-mongodb"
253+ assert_contains_string default/secret_my-redis.yaml " my-redis"
254+
212255# ###########################
213256# kpt fn Tests
214257# ###########################
273316kpt fn run .
274317grep -qR ' color: orange' .
275318grep -qR ' city: toronto' .
319+
320+ # TODO: Add kpt_helm_template_imperative_short and kpt_helm_template_declarative tests after fixing <https://github.com/GoogleContainerTools/kpt/issues/587>
321+ helm_testcase " kpt_helm_template_imperative"
322+ kpt fn source example-configs |
323+ docker run -i -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -d chart_path=/source/mongodb -d name=my-mongodb |
324+ docker run -i -u " $( id -u) " -v " $( pwd) /${CHARTS_SRC} " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -d name=my-redis -d chart_path=/source/redis |
325+ kpt fn sink example-configs
326+ assert_dir_exists example-configs/default
327+ assert_contains_string example-configs/default/secret_my-mongodb.yaml " my-mongodb"
328+ assert_contains_string example-configs/default/secret_my-redis.yaml " my-redis"
0 commit comments