Newer
Older
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
103
104
105
106
107
#!/usr/bin/env bats
# Load the bats-assert library
load 'node_modules/bats-assert/load.bash'
load 'node_modules/bats-support/load.bash'
BIGBANG_HOME=../
diag() {
echo "# $@" >&3
}
valid() {
TEST_DIR=test-values/$1/valid
find $TEST_DIR -type f | while read file; do
diag "Testing $file"
run helm template $BIGBANG_HOME/chart --values=$file
assert_equal "$status" "0"
done
}
invalid() {
TEST_DIR=test-values/$1/invalid
find $TEST_DIR -type f | while read file; do
diag "Testing $file"
run helm template $BIGBANG_HOME/chart --values=$file
assert_equal "$status" "1"
done
}
# Test basic schema validation
@test "helm template validate schema" {
run helm template $BIGBANG_HOME/chart
assert_equal "$status" "0"
}
# Test basic schema validation failure
@test "helm template validate schema failure" {
run helm template $BIGBANG_HOME/chart --set=neuvector.sso.foo=true
assert_equal "$status" "1"
}
# Test umbrella validation
@test "helm template validate umbrella schema" {
valid umbrella
invalid umbrella
}
# Test git schema validation
@test "helm template validate schema git" {
valid git
invalid git
}
# Test registryCredentials schema validation
@test "helm template validate schema registryCredentials" {
valid registry-credentials
invalid registry-credentials
}
# Test basePackage git schema validation
@test "helm template validate basePackage schema" {
valid base-package
invalid base-package
}
# Test basePackage git schema validation
@test "helm template validate git basePackage schema" {
valid base-package-git
invalid base-package-git
}
# Test basePackage sso schema validation
@test "helm template validate sso schema" {
valid base-package-sso
invalid base-package-sso
}
# Test basePackage helmRepo schema validation
@test "helm template validate helmRepo schema" {
valid base-package-helm-repo
invalid base-package-helm-repo
}
# Test basePackage source type schema validation
@test "helm template validate source type schema" {
valid base-package-source-type
invalid base-package-source-type
}
# Test basePackage source type schema validation
@test "helm template validate addons schema" {
valid addons
invalid addons
}
# Ensure core packages cannot have extra keys
@test "helm template validate core package no extra keys" {
local PACKAGES=$(yq e '.[] | select(. | (has("git") or has("oci"))) | path | .[-1]' $BIGBANG_HOME/chart/values.yaml)
for package in $PACKAGES; do
run helm template $BIGBANG_HOME/chart --set=$package.extra=key --values=$file
diag "Testing extra keys for core package $package"
assert_equal "$status" "1"
done
}
# Test monitoring schema validation
@test "helm template validate monitoring schema" {
valid monitoring
invalid monitoring