feat: add option to overwrite KUBECONFORM_CONFIG
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Robert Kaussow 2023-03-08 13:45:11 +01:00
parent 3931742f41
commit 6e6cb9e027
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
1 changed files with 15 additions and 13 deletions

View File

@ -35,22 +35,24 @@ find "${FLUX_PATH%/}" -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\
yq e 'true' "$file" >/dev/null
done
kubeconform_config=(
"-strict"
"-schema-location" "default"
"-schema-location" "/etc/kube-tools/schemas/flux"
"-schema-location" "/etc/kube-tools/schemas/calico/master-standalone-strict/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json"
"-schema-location" "/etc/kube-tools/schemas/cert-manager/master-standalone-strict/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json"
"-schema-location" "/etc/kube-tools/schemas/cloudnative-pg/master-standalone-strict/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json"
"-exit-on-error"
"-summary"
"-skip" "Secret,CustomResourceDefinition"
)
if [ -z "$KUBECONFORM_CONFIG" ]; then
KUBECONFORM_CONFIG=(
"-strict"
"-schema-location" "default"
"-schema-location" "https://gitea.rknet.org/infra/crds-catalog/raw/branch/catalog/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json"
"-exit-on-error"
"-summary"
"-skip" "Secret,CustomResourceDefinition"
)
else
# shellcheck disable=SC2128
IFS=', ' read -r -a KUBECONFORM_CONFIG <<<"$KUBECONFORM_CONFIG"
fi
printf "\nINFO - Validating clusters\n"
find "${FLUX_PATH%/}/clusters" -maxdepth 2 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file; do
printf "INFO - Validating cluster file %s\n" "${file}"
kubeconform "${kubeconform_config[@]}" "${file}"
kubeconform "${KUBECONFORM_CONFIG[@]}" "${file}"
if [[ ${PIPESTATUS[0]} != 0 ]]; then
exit 1
fi
@ -60,7 +62,7 @@ printf "\nINFO - Validating kustomize overlays\n"
find "${FLUX_PATH%/}" -type f -name $KUSTOMIZE_CONFIG -print0 | while IFS= read -r -d $'\0' file; do
printf "INFO - Validating kustomization %s\n" "${file/%$KUSTOMIZE_CONFIG/}"
kustomize build "${file/%$KUSTOMIZE_CONFIG/}" "${KUSTOMIZE_FLAGS[@]}" |
kubeconform "${kubeconform_config[@]}"
kubeconform "${KUBECONFORM_CONFIG[@]}"
echo
if [[ ${PIPESTATUS[0]} != 0 ]]; then
exit 1