Skip to content

Commit

Permalink
Check OBSERVABILITY_CONFIG_ACCESS_TOKEN can be used to access the con…
Browse files Browse the repository at this point in the history
…fig repo

Why:
An expired github personal access token causes a failure late in the
deployment, we can make it explode early.
  • Loading branch information
robobario committed Sep 27, 2022
1 parent cf911b4 commit 87ad4f3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions kas-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ read_kas_installer_env_file() {
fi
}

check_observability_token() {
echo "Checking validity of OBSERVABILITY_CONFIG_ACCESS_TOKEN"
curl --silent \
--head \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${OBSERVABILITY_CONFIG_ACCESS_TOKEN}" \
${OBSERVABILITY_CONFIG_REPO} \
--fail > /dev/null \
|| ( echo "failed to get observability config repo contents with OBSERVABILITY_CONFIG_ACCESS_TOKEN, check expiry and permissions" && exit 1 )
echo "OBSERVABILITY_CONFIG_ACCESS_TOKEN valid"
}

generate_kas_fleet_manager_env_config() {
echo "Generating KAS Fleet Manager configuration env file '${KAS_FLEET_MANAGER_DEPLOY_ENV_FILE} ...'"
# Make sure KAS Fleet Manager env file is empty
Expand Down Expand Up @@ -169,6 +181,7 @@ deploy_observatorium() {
# Main body of the script starts here

read_kas_installer_env_file
check_observability_token

# Deploy and configure MAS SSO
if [ "${SSO_PROVIDER_TYPE}" = "mas_sso" ] || [ -z "${MAS_SSO_BASE_URL:-}" ] ; then
Expand Down

0 comments on commit 87ad4f3

Please sign in to comment.