Allow validate script to read airship config

Changed the validate script to read the airship config file for manifest
root, site root, and repo url values. This enables the use case where
the user runs the init_site script and creates their own project and
site folder outside of the treasuremap directory strucuture.

Change-Id: I0eefdc385bffa600f5e942cec14f42ebd392782f
This commit is contained in:
James Gu 2021-06-07 15:00:55 -04:00
parent 3277230b03
commit 663527ceeb

View File

@ -17,9 +17,21 @@
set -xe
: ${AIRSHIPCTL_PROJECT:="../airshipctl"}
: ${MANIFEST_ROOT:="$(dirname "${PWD}")"}
: ${SITE_ROOTS:="$(basename "${PWD}")/manifests/site"}
: ${MANIFEST_REPO_URL:="https://review.opendev.org/airship/treasuremap"}
: ${CURRENT_MANIFEST:="$(airshipctl config get-contexts --current 2> /dev/null | \
yq '.contexts."ephemeral-cluster".manifest' | \
sed 's/"//g')"}
: ${PRIMARY_REPO:="$(airshipctl config get-manifest $CURRENT_MANIFEST 2> /dev/null | \
yq .${CURRENT_MANIFEST}.phaseRepositoryName | \
sed 's/"//g')"}
: ${MANIFEST_REPO_URL:="$(airshipctl config get-manifest $CURRENT_MANIFEST 2> /dev/null | \
yq .${CURRENT_MANIFEST}.repositories.${PRIMARY_REPO}.url | \
sed 's/"//g')"}
: ${MANIFEST_ROOT:="$(airshipctl config get-manifest $CURRENT_MANIFEST 2> /dev/null | \
yq .${CURRENT_MANIFEST}.targetPath | \
sed 's/"//g')"}
: ${PROJECT:="treasuremap"}
: ${SITE_ROOTS:="${PROJECT}/manifests/site"}
export MANIFEST_ROOT=$MANIFEST_ROOT
export SITE_ROOTS=$SITE_ROOTS
export MANIFEST_REPO_URL=$MANIFEST_REPO_URL