openstack-helm-infra/tools/gate/lint.sh
Gage Hugo 67ac5da9ed Update helm repo url
The googleapi repo has been causing issues and the latest
one is giving an unauthorized error when trying to download
helm tarball.

This change moves the repo to use the official helm one.

Change-Id: I52607b0ca6d650d5f5e4a95045389970faa08cfb
2021-08-11 16:18:44 +00:00

36 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -e
HELM_DATA_YAML=../openstack-helm-infra/roles/build-helm-packages/defaults/main.yml
HELM_VERSION=$(yq -r '.version.helm' ${HELM_DATA_YAML})
HELM_REPO_URL=$(yq -r '.url.helm_repo' ${HELM_DATA_YAML})
LINT_DIR=.yamllint
rm -rf */charts/helm-toolkit
mkdir ${LINT_DIR}
cp -r * ${LINT_DIR}
rm -rf ${LINT_DIR}/*/templates
wget -qO ${LINT_DIR}/helm.tgz ${HELM_REPO_URL}/helm-${HELM_VERSION}-linux-amd64.tar.gz
tar xzf ${LINT_DIR}/helm.tgz -C ${LINT_DIR} --strip-components=1 linux-amd64/helm
for i in */; do
# avoid helm-toolkit to symlink on itself
[ -d "$i/templates" -a "$i" != "helm-toolkit/" ] || continue
mkdir -p $i/charts
ln -s ../../../openstack-helm-infra/helm-toolkit $i/charts/helm-toolkit
${LINT_DIR}/helm template $i --output-dir ${LINT_DIR} 2>&1 > /dev/null
done
rm -rf */charts/helm-toolkit
find .yamllint -type f -exec sed -i 's/%%%.*/XXX/g' {} +
set +e
shopt -s globstar extglob
# lint all y*mls except for templates with the first config
yamllint -c yamllint.conf ${LINT_DIR}/*{,/!(templates)/**}/*.y*ml yamllint*.conf
result=$?
# lint templates with the second config
yamllint -c yamllint-templates.conf ${LINT_DIR}/*/templates/*.yaml
exit $(($?|$result))