Skip to content

Commit b8d4bd0

Browse files
author
George Khoury
committed
update flux script to latest version
1 parent d1432c9 commit b8d4bd0

File tree

1 file changed

+22
-32
lines changed

1 file changed

+22
-32
lines changed

scripts/validate-flux.sh

Lines changed: 22 additions & 32 deletions
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 2020 The Flux authors. All rights reserved.
8+
# Copyright 2022 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.
@@ -24,54 +24,44 @@
2424
# the branch synced by Flux in-cluster.
2525

2626
# Prerequisites
27-
# - yq v4.6
28-
# - kustomize v4.1
29-
# - kubeconform v0.4.12
30-
31-
type yq >/dev/null 2>&1 || {
32-
echo >&2 "yq is not installed. Please install it to be able to run the script. Aborting."
33-
exit 1
34-
}
35-
type kustomize >/dev/null 2>&1 || {
36-
echo >&2 "kustomize is not installed. Please install it to be able to run the script. Aborting."
37-
exit 1
38-
}
39-
type kubeconform >/dev/null 2>&1 || {
40-
echo >&2 " kubeconform is not installed. Please install it to be able to run the script. Aborting."
41-
exit 1
42-
}
27+
# - yq v4.30
28+
# - kustomize v4.5
29+
# - kubeconform v0.5.0
4330

4431
set -o errexit
4532

4633
echo "INFO - Downloading Flux OpenAPI schemas"
4734
mkdir -p /tmp/flux-crd-schemas/master-standalone-strict
4835
curl -sL https://github.com/fluxcd/flux2/releases/latest/download/crd-schemas.tar.gz | tar zxf - -C /tmp/flux-crd-schemas/master-standalone-strict
4936

50-
find . -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file; do
51-
echo "INFO - Validating $file"
52-
yq e 'true' "$file" >/dev/null
37+
find . -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
38+
do
39+
echo "INFO - Validating $file"
40+
yq e 'true' "$file" > /dev/null
5341
done
5442

5543
kubeconform_config=("-strict" "-ignore-missing-schemas" "-schema-location" "default" "-schema-location" "/tmp/flux-crd-schemas" "-verbose")
5644

5745
echo "INFO - Validating clusters"
58-
find ./clusters -maxdepth 2 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file; do
59-
kubeconform "${kubeconform_config[@]}" "${file}"
60-
if [[ ${PIPESTATUS[0]} != 0 ]]; then
61-
exit 1
62-
fi
46+
find ./clusters -maxdepth 2 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
47+
do
48+
kubeconform "${kubeconform_config[@]}" "${file}"
49+
if [[ ${PIPESTATUS[0]} != 0 ]]; then
50+
exit 1
51+
fi
6352
done
6453

6554
# mirror kustomize-controller build options
6655
kustomize_flags=("--load-restrictor=LoadRestrictionsNone")
6756
kustomize_config="kustomization.yaml"
6857

6958
echo "INFO - Validating kustomize overlays"
70-
find . -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' file; do
71-
echo "INFO - Validating kustomization ${file/%$kustomize_config/}"
72-
kustomize build "${file/%$kustomize_config/}" "${kustomize_flags[@]}" |
73-
kubeconform "${kubeconform_config[@]}"
74-
if [[ ${PIPESTATUS[0]} != 0 ]]; then
75-
exit 1
76-
fi
59+
find . -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' file;
60+
do
61+
echo "INFO - Validating kustomization ${file/%$kustomize_config}"
62+
kustomize build "${file/%$kustomize_config}" "${kustomize_flags[@]}" | \
63+
kubeconform "${kubeconform_config[@]}"
64+
if [[ ${PIPESTATUS[0]} != 0 ]]; then
65+
exit 1
66+
fi
7767
done

0 commit comments

Comments
 (0)