feat: add option to overwrite KUBECONFORM_CONFIG
All checks were successful
continuous-integration/drone/push Build is passing

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

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