From 7712122277a9ab1be40125bed59b8f878cc5c830 Mon Sep 17 00:00:00 2001 From: Max Goltzsche Date: Sun, 21 Jul 2024 00:10:48 +0200 Subject: [PATCH] chore: add output path mapping e2e test --- e2e/kpt-krm-fn-tests.bats | 12 ++++++++++++ example/kpt/output-mapping/Makefile | 4 ++++ example/kpt/output-mapping/fn-config.yaml | 17 +++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 example/kpt/output-mapping/Makefile create mode 100644 example/kpt/output-mapping/fn-config.yaml diff --git a/e2e/kpt-krm-fn-tests.bats b/e2e/kpt-krm-fn-tests.bats index db937df..06ce7d5 100755 --- a/e2e/kpt-krm-fn-tests.bats +++ b/e2e/kpt-krm-fn-tests.bats @@ -78,6 +78,18 @@ teardown() { grep -q cainjector ./output-remote.yaml } +@test "kpt imperative fn should map output" { + cd example/kpt/output-mapping + rm -f output-default.yaml output-filtered.yaml + make fn + + [ -f ./output-default.yaml ] + [ -f ./output-filtered.yaml ] + grep -q cainjector ./output-default.yaml + grep -Eq '^kind: ConfigMap$' ./output-filtered.yaml + ! grep -Eq '^kind: ConfigMap$' ./output-default.yaml +} + @test "kpt declarative fn should render built-in chart" { cd example/kpt/declarative rm -rf generated diff --git a/example/kpt/output-mapping/Makefile b/example/kpt/output-mapping/Makefile new file mode 100644 index 0000000..961854c --- /dev/null +++ b/example/kpt/output-mapping/Makefile @@ -0,0 +1,4 @@ +IMAGE ?= mgoltzsche/khelm:latest + +fn: + kpt fn eval --network --image="$(IMAGE)" --fn-config=./fn-config.yaml . --truncate-output=false diff --git a/example/kpt/output-mapping/fn-config.yaml b/example/kpt/output-mapping/fn-config.yaml new file mode 100644 index 0000000..f60d17a --- /dev/null +++ b/example/kpt/output-mapping/fn-config.yaml @@ -0,0 +1,17 @@ +apiVersion: khelm.mgoltzsche.github.com/v2 +kind: ChartRenderer +metadata: + name: remote-chart + annotations: + config.kubernetes.io/local-config: "true" +repository: https://charts.jetstack.io +chart: cert-manager +version: 1.10.2 +name: myrelease +debug: true +outputPath: output-default.yaml +outputPathMapping: +- outputPath: output-filtered.yaml + selectors: + - kind: ConfigMap + name: myrelease-cert-manager-webhook