5
5
# This script is meant to be run locally and in CI before the changes
6
6
# are merged on the main branch that's synced by Flux.
7
7
8
- # Copyright 2022 The Flux authors. All rights reserved.
8
+ # Copyright 2023 The Flux authors. All rights reserved.
9
9
#
10
10
# Licensed under the Apache License, Version 2.0 (the "License");
11
11
# you may not use this file except in compliance with the License.
19
19
# See the License for the specific language governing permissions and
20
20
# limitations under the License.
21
21
22
- # This script is meant to be run locally and in CI to validate the Kubernetes
23
- # manifests (including Flux custom resources) before changes are merged into
24
- # the branch synced by Flux in-cluster.
25
-
26
22
# Prerequisites
27
- # - yq v4.30
28
- # - kustomize v4.5
29
- # - kubeconform v0.5.0
23
+ # - yq v4.34
24
+ # - kustomize v5.0
25
+ # - kubeconform v0.6
30
26
31
27
set -o errexit
28
+ set -o pipefail
29
+
30
+ # mirror kustomize-controller build options
31
+ kustomize_flags=(" --load-restrictor=LoadRestrictionsNone" )
32
+ kustomize_config=" kustomization.yaml"
33
+
34
+ # skip Kubernetes Secrets due to SOPS fields failing validation
35
+ kubeconform_flags=(" -skip=Secret" )
36
+ kubeconform_config=(" -strict" " -ignore-missing-schemas" " -schema-location" " default" " -schema-location" " /tmp/flux-crd-schemas" " -verbose" )
32
37
33
38
echo " INFO - Downloading Flux OpenAPI schemas"
34
39
mkdir -p /tmp/flux-crd-schemas/master-standalone-strict
@@ -40,28 +45,22 @@ find . -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
40
45
yq e ' true' " $file " > /dev/null
41
46
done
42
47
43
- kubeconform_config=(" -strict" " -ignore-missing-schemas" " -schema-location" " default" " -schema-location" " /tmp/flux-crd-schemas" " -verbose" )
44
-
45
48
echo " INFO - Validating clusters"
46
49
find ./clusters -maxdepth 2 -type f -name ' *.yaml' -print0 | while IFS= read -r -d $' \0' file;
47
50
do
48
- kubeconform " ${kubeconform_config[@]} " " ${file} "
51
+ kubeconform " ${kubeconform_flags[@]} " " ${ kubeconform_config[@]}" " ${file} "
49
52
if [[ ${PIPESTATUS[0]} != 0 ]]; then
50
53
exit 1
51
54
fi
52
55
done
53
56
54
- # mirror kustomize-controller build options
55
- kustomize_flags=(" --load-restrictor=LoadRestrictionsNone" )
56
- kustomize_config=" kustomization.yaml"
57
-
58
57
echo " INFO - Validating kustomize overlays"
59
58
find . -type f -name $kustomize_config -print0 | while IFS= read -r -d $' \0' file;
60
59
do
61
60
echo " INFO - Validating kustomization ${file/% $kustomize_config } "
62
61
kustomize build " ${file/% $kustomize_config } " " ${kustomize_flags[@]} " | \
63
- kubeconform " ${kubeconform_config[@]} "
62
+ kubeconform " ${kubeconform_flags[@]} " " ${ kubeconform_config[@]}"
64
63
if [[ ${PIPESTATUS[0]} != 0 ]]; then
65
64
exit 1
66
65
fi
67
- done
66
+ done
0 commit comments