-
Notifications
You must be signed in to change notification settings - Fork 11
/
kpt-krm-fn-tests.bats
executable file
·102 lines (86 loc) · 3.02 KB
/
kpt-krm-fn-tests.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bats
set -eu
: ${IMAGE:=mgoltzsche/khelm:latest}
EXAMPLE_CHART_NAMESPACE="`pwd`/example/namespace"
TMP_DIR="$(mktemp -d)"
teardown() {
rm -rf $TMP_DIR
}
@test "kpt imperative fn should render local-chart" {
cd example/kpt/local-chart
rm -rf output
mkdir output
make fn
[ -f ./output/output.yaml ]
grep -q jenkins-role-binding ./output/output.yaml
}
@test "kpt imperative fn should cache chart dependency" {
cd example/kpt/local-chart
rm -rf output
mkdir output
kpt fn eval --image="$IMAGE" --fn-config=./fn-config.yaml \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,source=`pwd`/../..,target=/examples,rw=true" \
--as-current-user output --network
kpt fn eval --image="$IMAGE" --fn-config=./fn-config.yaml \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,source=`pwd`/../..,target=/examples,rw=true" \
--as-current-user output --truncate-output=false --network
[ -f ./output/output.yaml ]
grep -q jenkins-role-binding ./output/output.yaml
grep -qv myconfiga ./output/output.yaml
}
@test "kpt imperative fn should convert parameterized chart into kustomization" {
cd example/kpt/chart-to-kustomization
rm -rf output-kustomization
make fn
[ -f ./output-kustomization/configmap_myconfiga.yaml ]
[ -f ./output-kustomization/configmap_myconfigb.yaml ]
[ -f ./output-kustomization/kustomization.yaml ]
kustomize build ./output-kustomization | grep -q ' myconfiga'
}
@test "kpt imperative fn should render remote chart" {
cd example/kpt/remote-chart
rm -f output-remote.yaml
make fn
[ -f ./output-remote.yaml ]
grep -q cainjector ./output-remote.yaml
}
@test "kpt imperative fn should cache remote chart" {
cd example/kpt/remote-chart
rm -f output-remote.yaml
kpt fn eval --as-current-user --network \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,src=$EXAMPLE_CHART_NAMESPACE,dst=/source" \
--image="$IMAGE" \
--fn-config=./fn-config.yaml .
[ -f ./output-remote.yaml ]
rm -f output-remote.yaml
ls -la $TMP_DIR/cache/khelm
kpt fn eval --as-current-user \
--mount "type=bind,src=$TMP_DIR,dst=/helm,rw=true" \
--mount "type=bind,src=$EXAMPLE_CHART_NAMESPACE,dst=/source" \
--image="$IMAGE" \
--fn-config=./fn-config.yaml .
[ -f ./output-remote.yaml ]
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
make render
[ -f ./generated/kustomization.yaml ]
[ -f ./generated/deployment_myrelease-cert-manager.yaml ]
grep -q myrelease-cert-manager ./generated/deployment_myrelease-cert-manager.yaml
grep -q ' namespace: "mynamespace"' ./generated/deployment_myrelease-cert-manager.yaml
}