Skip to content

Commit

Permalink
Fixes migration to 2.0 path errors
Browse files Browse the repository at this point in the history
Genesis 2.8 modified how the `bosh` helper function which changes the
current path context.  Because it now uses the genesis repo path,
relative paths such as files in the kit need to be referenced fully.

Also bump min genesis version to 2.7.23 because of limitation on using
rc min versions.
  • Loading branch information
dennisjbell committed Nov 1, 2023
1 parent af324a3 commit c3c17bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions hooks/migrate-to-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
migrate_credentials_to_credhub() {
vault_prefix=${GENESIS_SECRETS_MOUNT}${GENESIS_SECRETS_SLUG}
vault_paths=$(safe paths --keys ${vault_prefix} | jq -c -R -s 'split("\n") | map(select(length > 0))')
[[ -n "$GENESIS_KIT_PATH" ]] || export GENESIS_KIT_PATH="$PWD"
[[ -n "$GENESIS_BOSH_COMMAND" ]] || export GENESIS_BOSH_COMMAND=`type -P bosh bosh2 bosh-cli | head -n1`
credhub import -f <( \
bosh int ./hooks/support/vault-credhub-mapping.yml \
-v=credhub_prefix=$GENESIS_CREDHUB_ROOT -v=vault_prefix=${vault_prefix#/} | spruce json \
$GENESIS_BOSH_COMMAND int "${GENESIS_KIT_PATH}/hooks/support/vault-credhub-mapping.yml" \
-v=credhub_prefix="$GENESIS_CREDHUB_ROOT" -v=vault_prefix=${vault_prefix#/} | spruce json \
| jq --argjson paths $vault_paths '.credentials | map(select(.value | try .private_key // . | split("\"")[1] | IN($paths[]))) | {credentials: .}' \
| spruce merge )

external_db_user=$(credhub get -n ${GENESIS_CREDHUB_ROOT}/external_db_user -j 2>/dev/null | jq -r '.value')
external_db_user=$(credhub get -n "${GENESIS_CREDHUB_ROOT}/external_db_user" -j 2>/dev/null | jq -r '.value')
if [[ ${external_db_user} != "" ]] ; then
describe >&2 "#Y{{WARNING}} You must set params.external_db_user to '((external_db_user))' "\
"in your #C{$GENESIS_ENVIRONMENT.yml} to use the username that was located in vault"
Expand Down
2 changes: 1 addition & 1 deletion kit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ required_configs:
- cloud
- runtime

genesis_version_min: 2.7.23-rc1
genesis_version_min: 2.7.23
secrets_store: credhub

0 comments on commit c3c17bc

Please sign in to comment.