diff --git a/cli/createTemplate.sh b/cli/createTemplate.sh index 519135a1..79b6dc8c 100755 --- a/cli/createTemplate.sh +++ b/cli/createTemplate.sh @@ -151,14 +151,14 @@ function options() { else debug "Using CMDB composites" - if [[ -n "${DEPLOYMENT_GROUP}" ]]; then - case "${DEPLOYMENT_GROUP}" in + if [[ -n "${DISTRICT_TYPE}" ]]; then + case "${DISTRICT_TYPE}" in account) [[ -z "${ACCOUNT_DIR}" ]] && fatalLocation "Could not find ACCOUNT_DIR directory for account: \"${ACCOUNT}\"" && return 1 ;; - *) + segment) [[ -z "${SEGMENT_SOLUTIONS_DIR}" ]] && fatalLocation "Cound not find SEGMENT_SOLUTIONS_DIR directory for segment \"${SEGMENT}\"" && return 1 ;; @@ -669,13 +669,14 @@ function process_template_pass() { } function process_template() { - local entrance="${1,,}"; shift - local flows="${1,,}"; shift - local deployment_unit="${1,,}"; shift - local deployment_group="${1,,}"; shift - local account="$1"; shift - local account_region="${1,,}"; shift - local region="${1,,}"; shift + local entrance="${1}"; shift + local flows="${1}"; shift + local district_type="${1}"; shift + local deployment_unit="${1}"; shift + local deployment_group="${1}"; shift + local account="${1}"; shift + local account_region="${1}"; shift + local region="${1}"; shift local request_reference="${1}"; shift local configuration_reference="${1}"; shift local deployment_mode="${1}"; shift @@ -686,47 +687,42 @@ function process_template() { local template_alternatives=("primary") local cleanup_level="${deployment_group}" - case "${entrance}" in + case "${district_type}" in + account) + local cf_dir_default="${ACCOUNT_STATE_DIR}/cf/shared" + ;; + segment) + local cf_dir_default="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" + ;; + esac + + + case "${entrance}" in schema) local cf_dir_default="${PRODUCT_STATE_DIR}/hamlet" ;; deployment) case "${deployment_group}" in - account) - local cf_dir_default="${ACCOUNT_STATE_DIR}/cf/shared" - ;; - - product) - local cf_dir_default="${PRODUCT_STATE_DIR}/cf/shared" - ;; - application) - local cf_dir_default="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" cleanup_level="app" ;; solution) - local cf_dir_default="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" cleanup_level="soln" ;; segment) - local cf_dir_default="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" cleanup_level="seg" ;; *) - local cf_dir_default="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" cleanup_level="${deployment_group}" ;; esac ;; - *) - local cf_dir_default="${PRODUCT_STATE_DIR}/hamlet/${ENVIRONMENT}/${SEGMENT}" - ;; esac # Handle >=v2.0.1 cmdb where du/placement subdirectories were introduced for state @@ -990,6 +986,7 @@ function main() { process_template \ "${ENTRANCE}" \ "${FLOWS}" \ + "${DISTRICT_TYPE}" \ "${DEPLOYMENT_UNIT}" "${DEPLOYMENT_GROUP}" \ "${ACCOUNT}" "${ACCOUNT_REGION}" \ "${REGION}" \ diff --git a/execution/setStackContext.sh b/execution/setStackContext.sh index 4ab4418e..e991f53e 100755 --- a/execution/setStackContext.sh +++ b/execution/setStackContext.sh @@ -38,23 +38,29 @@ if [[ -n "${OUTPUT_DIR}" ]]; then fi if [[ -z "${OUTPUT_DIR}" ]]; then - # First determine the CF_DIR so we can handle deployment unit subdirectories - case $LEVEL in + + # First determine the CF_DIR so we can handle deployment unit subdirectories + case "${DISTRICT_TYPE}" in account) + PRODUCT_PREFIX="${ACCOUNT}" + ENVIRONMENT_SUFFIX="" + SEGMENT_SUFFIX="" CF_DIR="${ACCOUNT_STATE_DIR}/cf/shared" - REGION="${ACCOUNT_REGION}" - REGION_PREFIX="${ACCOUNT_REGION}-" - ;; - - product) - CF_DIR="${PRODUCT_STATE_DIR}/cf/shared" ;; - solution|segment|application|multiple) + segment) CF_DIR="${PRODUCT_STATE_DIR}/cf/${ENVIRONMENT}/${SEGMENT}" ;; + *) - fatalCantProceed "\"$LEVEL\" is not one of the known stack levels." + fatalCantProceed "\"${DISTRICT_TYPE}\" is not a supported district type - account or segment are currently supported" + ;; + esac + + case "${LEVEL}" in + account) + REGION="${ACCOUNT_REGION}" + REGION_PREFIX="${ACCOUNT_REGION}-" ;; esac @@ -70,12 +76,8 @@ if [[ -z "${OUTPUT_DIR}" ]]; then fi fi -case $LEVEL in +case "${LEVEL}" in account) - PRODUCT_PREFIX="${ACCOUNT}" - ENVIRONMENT_SUFFIX="" - SEGMENT_SUFFIX="" - # LEGACY: Support stacks created before deployment units added to account if [[ "${DEPLOYMENT_UNIT}" =~ s3 ]]; then if [[ -f "${CF_DIR}/${LEVEL_PREFIX}${REGION_PREFIX}template.json" ]]; then @@ -91,19 +93,6 @@ case $LEVEL in fi ;; - product) - ENVIRONMENT_SUFFIX="" - SEGMENT_SUFFIX="" - - # LEGACY: Support stacks created before deployment units added to product - if [[ "${DEPLOYMENT_UNIT}" =~ cmk ]]; then - if [[ -f "${CF_DIR}/${LEVEL_PREFIX}${REGION_PREFIX}template.json" ]]; then - DEPLOYMENT_UNIT_PREFIX="" - DEPLOYMENT_UNIT_SUFFIX="" - fi - fi - ;; - solution) LEVEL_PREFIX="soln-" LEVEL_SUFFIX="-soln" @@ -119,26 +108,6 @@ case $LEVEL in LEVEL_PREFIX="seg-" LEVEL_SUFFIX="-seg" - # LEGACY: Support old formats for existing stacks so they can be updated - if [[ !("${DEPLOYMENT_UNIT}" =~ cmk|cert|dns ) ]]; then - if [[ -f "${CF_DIR}/cont-${DEPLOYMENT_UNIT_PREFIX}${REGION_PREFIX}template.json" ]]; then - LEVEL_PREFIX="cont-" - LEVEL_SUFFIX="-cont" - fi - if [[ -f "${CF_DIR}/container-${REGION}-template.json" ]]; then - LEVEL_PREFIX="container-" - LEVEL_SUFFIX="-container" - DEPLOYMENT_UNIT_PREFIX="" - DEPLOYMENT_UNIT_SUFFIX="" - fi - if [[ -f "${CF_DIR}/${SEGMENT}-container-template.json" ]]; then - LEVEL_PREFIX="${SEGMENT}-container-" - LEVEL_SUFFIX="-container" - DEPLOYMENT_UNIT_PREFIX="" - DEPLOYMENT_UNIT_SUFFIX="" - REGION_PREFIX="" - fi - fi # "cmk" now used instead of "key" if [[ "${DEPLOYMENT_UNIT}" == "cmk" ]]; then if [[ -f "${CF_DIR}/${LEVEL_PREFIX}key-${REGION_PREFIX}template.json" ]]; then @@ -152,15 +121,6 @@ case $LEVEL in LEVEL_PREFIX="app-" LEVEL_SUFFIX="-app" ;; - - multiple) - LEVEL_PREFIX="multi-" - LEVEL_SUFFIX="-multi" - ;; - - *) - fatalCantProceed "\"$LEVEL\" is not one of the known stack levels." - ;; esac STACK_NAME="${STACK_NAME:-${PRODUCT_PREFIX}${ENVIRONMENT_SUFFIX}${SEGMENT_SUFFIX}${LEVEL_SUFFIX}${DEPLOYMENT_UNIT_SUFFIX}${DEPLOYMENT_UNIT_SUBSET_SUFFIX}}"