From c3c17bcbf270325a54af78498866058c4d531702 Mon Sep 17 00:00:00 2001 From: "Dennis J. Bell" Date: Wed, 1 Nov 2023 11:44:36 -0700 Subject: [PATCH] Fixes migration to 2.0 path errors 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. --- hooks/migrate-to-2.0 | 8 +++++--- kit.yml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hooks/migrate-to-2.0 b/hooks/migrate-to-2.0 index 59ac2a0e..02602b0f 100755 --- a/hooks/migrate-to-2.0 +++ b/hooks/migrate-to-2.0 @@ -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" diff --git a/kit.yml b/kit.yml index e74369b0..29018779 100644 --- a/kit.yml +++ b/kit.yml @@ -16,5 +16,5 @@ required_configs: - cloud - runtime -genesis_version_min: 2.7.23-rc1 +genesis_version_min: 2.7.23 secrets_store: credhub