@@ -28,7 +28,6 @@ metadata:
2828items: []
2929EOF
3030)
31- CHARTS_SRC=" charts/bitnami"
3231
3332# ###########################
3433# Test framework
@@ -41,24 +40,11 @@ function testcase() {
4140 cd " ${tmp} "
4241}
4342
44- function helm_testcase() {
45- echo " testcase: ${1} "
46- tmp=$( mktemp -d " /tmp/e2e.${1} .XXXXXXXX" )
47- cp -r " ${REPO} " /example-configs " ${tmp} "
48- cd " ${tmp} "
49- git clone -q https://github.com/bitnami/charts.git
50- }
51-
5243function fail() {
5344 echo " FAIL: " " $@ "
5445 exit 1
5546}
5647
57- function assert_contains_string() {
58- content=" $( < " $1 " ) "
59- grep -q " $2 " " $1 " || fail " String $2 not contained in: ${content} "
60- }
61-
6248function assert_empty_list() {
6349 content=" $( < " $1 " ) "
6450 [[ ${content} = " ${EMPTY_OUTPUT} " ]] || fail " Not empty list: ${content} "
@@ -176,43 +162,6 @@ assert_dir_exists payments-dev
176162assert_dir_exists payments-prod
177163grep -q allowPrivilegeEscalation podsecuritypolicy_psp.yaml
178164
179- helm_testcase " docker_helm_template_expected_args"
180- 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
181- assert_contains_string out.yaml " expected-args"
182-
183- helm_testcase " docker_helm_template_extra_args"
184- cat > fc.yaml << EOF
185- apiVersion: v1
186- kind: ConfigMap
187- metadata:
188- name: my-config
189- annotations:
190- config.k8s.io/function: |
191- container:
192- image: gcr.io/kpt-functions/helm-template
193- config.kubernetes.io/local-config: "true"
194- data:
195- name: extra-args
196- chart_path: /source/charts/bitnami/redis
197- --values: /source/charts/bitnami/redis/values-production.yaml
198- EOF
199- docker run -u " $( id -u) " -v " $( pwd) " :/source gcr.io/kpt-functions/helm-template:" ${TAG} " -i /dev/null -f /source/fc.yaml > out.yaml
200- assert_contains_string out.yaml " extra-args"
201-
202- helm_testcase " docker_helm_template_sink"
203- 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 |
204- 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
205- assert_dir_exists default
206- assert_contains_string default/secret_sink-redis.yaml " sink-redis"
207-
208- helm_testcase " docker_helm_template_pipeline"
209- 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 |
210- 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 |
211- 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
212- assert_dir_exists default
213- assert_contains_string default/secret_my-mongodb.yaml " my-mongodb"
214- assert_contains_string default/secret_my-redis.yaml " my-redis"
215-
216165# ###########################
217166# kpt fn Tests
218167# ###########################
277226kpt fn run .
278227grep -qR ' color: orange' .
279228grep -qR ' city: toronto' .
280-
281- # TODO: Add kpt_helm_template_imperative_short and kpt_helm_template_declarative tests after fixing <https://github.com/GoogleContainerTools/kpt/issues/587>
282- helm_testcase " kpt_helm_template_imperative"
283- kpt fn source example-configs |
284- 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 |
285- 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 |
286- kpt fn sink example-configs
287- assert_dir_exists example-configs/default
288- assert_contains_string example-configs/default/secret_my-mongodb.yaml " my-mongodb"
289- assert_contains_string example-configs/default/secret_my-redis.yaml " my-redis"
0 commit comments