Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Fix to allow release without an Admin Key
Browse files Browse the repository at this point in the history
  • Loading branch information
mars committed Sep 17, 2018
1 parent 191d3bc commit ebbe4f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bin/prerelease
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ set -u
psql $DATABASE_URL -c "SELECT 1 FROM consumers"
data_exists=$?

if [ ! $data_exists -eq 0 ] && [ -n "$KONG_HEROKU_ADMIN_KEY" ]
# Admin key is empty when the var is unset.
admin_key="${KONG_HEROKU_ADMIN_KEY:-}"

if [ ! $data_exists -eq 0 ] && [ -n "$admin_key" ]
then
echo "Loading base Kong config to enable secure proxy to Admin API"
pg_restore --verbose --clean --no-acl --no-owner -d "$DATABASE_URL" $HOME/config/pg-heroku-admin.dump
fi

set -e

if [ -n "$KONG_HEROKU_ADMIN_KEY" ]
if [ -n "$admin_key" ]
then
echo "Setting Admin API key to value of KONG_HEROKU_ADMIN_KEY"
# This `id` matches the "kong-admin" keyauth_credentials record contained in "config/pg-heroku-admin.dump"
psql "$DATABASE_URL" -c "UPDATE keyauth_credentials SET key='$KONG_HEROKU_ADMIN_KEY' WHERE id='ac8af1d3-377a-41ae-9fd5-dbf98c599c5c';"
psql "$DATABASE_URL" -c "UPDATE keyauth_credentials SET key='${admin_key}' WHERE id='ac8af1d3-377a-41ae-9fd5-dbf98c599c5c';"
fi

0 comments on commit ebbe4f2

Please sign in to comment.