Skip to content

Commit b819619

Browse files
committed
Update validate-flux bash script
1 parent b8d4bd0 commit b819619

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

scripts/validate-flux.sh

+16-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This script is meant to be run locally and in CI before the changes
66
# are merged on the main branch that's synced by Flux.
77

8-
# Copyright 2022 The Flux authors. All rights reserved.
8+
# Copyright 2023 The Flux authors. All rights reserved.
99
#
1010
# Licensed under the Apache License, Version 2.0 (the "License");
1111
# you may not use this file except in compliance with the License.
@@ -19,16 +19,21 @@
1919
# See the License for the specific language governing permissions and
2020
# limitations under the License.
2121

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-
2622
# 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
3026

3127
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")
3237

3338
echo "INFO - Downloading Flux OpenAPI schemas"
3439
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;
4045
yq e 'true' "$file" > /dev/null
4146
done
4247

43-
kubeconform_config=("-strict" "-ignore-missing-schemas" "-schema-location" "default" "-schema-location" "/tmp/flux-crd-schemas" "-verbose")
44-
4548
echo "INFO - Validating clusters"
4649
find ./clusters -maxdepth 2 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
4750
do
48-
kubeconform "${kubeconform_config[@]}" "${file}"
51+
kubeconform "${kubeconform_flags[@]}" "${kubeconform_config[@]}" "${file}"
4952
if [[ ${PIPESTATUS[0]} != 0 ]]; then
5053
exit 1
5154
fi
5255
done
5356

54-
# mirror kustomize-controller build options
55-
kustomize_flags=("--load-restrictor=LoadRestrictionsNone")
56-
kustomize_config="kustomization.yaml"
57-
5857
echo "INFO - Validating kustomize overlays"
5958
find . -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' file;
6059
do
6160
echo "INFO - Validating kustomization ${file/%$kustomize_config}"
6261
kustomize build "${file/%$kustomize_config}" "${kustomize_flags[@]}" | \
63-
kubeconform "${kubeconform_config[@]}"
62+
kubeconform "${kubeconform_flags[@]}" "${kubeconform_config[@]}"
6463
if [[ ${PIPESTATUS[0]} != 0 ]]; then
6564
exit 1
6665
fi
67-
done
66+
done

0 commit comments

Comments
 (0)