Skip to content

Commit 0cf8a87

Browse files
authored
[#3111] Aborted Acquia hook wrappers on unset and empty required values. (#3120)
1 parent 6a8c624 commit 0cf8a87

23 files changed

Lines changed: 871 additions & 111 deletions

File tree

‎.vortex/docs/.utils/variables/extra/acquia.variables.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ VORTEX_PURGE_CACHE_ACQUIA_SKIP=
1515
# Skip Drupal site provisioning in Acquia environment.
1616
VORTEX_PROVISION_ACQUIA_SKIP=
1717

18+
# Skip sending of deployment notifications in Acquia environment.
19+
VORTEX_NOTIFY_ACQUIA_SKIP=
20+
1821
# NewRelic API key, usually of type 'USER'.
1922
#
2023
# @see https://www.vortextemplate.com/docs/deployment/notifications/newrelic

‎.vortex/docs/content/development/variables.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ The list below is automatically generated with [Shellvar](https://github.com/ale
322322
| <a id="vortex_login_container_registry_user"></a>`VORTEX_LOGIN_CONTAINER_REGISTRY_USER` | The username to login into the container registry.<br/><br/>If not provided, the script will skip the login step. | `${VORTEX_CONTAINER_REGISTRY_USER}` | `.vortex/tooling/src/vortex-login-container-registry` |
323323
| <a id="vortex_login_unblock_admin"></a>`VORTEX_LOGIN_UNBLOCK_ADMIN` | Flag to unblock admin. | `1` | `.vortex/tooling/src/vortex-login` |
324324
| <a id="vortex_logout_block_admin"></a>`VORTEX_LOGOUT_BLOCK_ADMIN` | Flag to block or unblock admin. | `1` | `.vortex/tooling/src/vortex-logout` |
325+
| <a id="vortex_notify_acquia_skip"></a>`VORTEX_NOTIFY_ACQUIA_SKIP` | Skip sending of deployment notifications in Acquia environment. | `UNDEFINED` | `ACQUIA ENVIRONMENT` |
325326
| <a id="vortex_notify_branch"></a>`VORTEX_NOTIFY_BRANCH` | Notification git branch name. | `UNDEFINED` | `.vortex/tooling/src/vortex-notify` |
326327
| <a id="vortex_notify_channels"></a>`VORTEX_NOTIFY_CHANNELS` | The channels of the notifications.<br/><br/>A combination of comma-separated values: email,slack,newrelic,github,jira,webhook,diffy | `email` | `.env`, `.vortex/tooling/src/vortex-notify` |
327328
| <a id="vortex_notify_diffy_branch"></a>`VORTEX_NOTIFY_DIFFY_BRANCH` | Diffy notification git branch name. | `${VORTEX_NOTIFY_BRANCH}` | `.vortex/tooling/src/vortex-notify-diffy` |

‎.vortex/docs/content/hosting/acquia.mdx‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ pre-configured scripts in the [`hooks/`](https://github.com/drevops/vortex/tree/
4343
directory that trigger on code deployments, code updates, and database copy
4444
operations.
4545

46+
Each hook is turned off by setting its skip variable to `1` in the Acquia UI:
47+
48+
| Hook | Variable |
49+
|------------------------|--------------------------------------|
50+
| `provision.sh` | `VORTEX_PROVISION_ACQUIA_SKIP` |
51+
| `purge-cache.sh` | `VORTEX_PURGE_CACHE_ACQUIA_SKIP` |
52+
| `notify-deployment.sh` | `VORTEX_NOTIFY_ACQUIA_SKIP` |
53+
| `copy-db.sh` | `VORTEX_TASK_COPY_DB_ACQUIA_SKIP` |
54+
| `copy-files.sh` | `VORTEX_TASK_COPY_FILES_ACQUIA_SKIP` |
55+
56+
A hook stops with an error when a value it requires is unset or empty, so a
57+
blank field in the Acquia UI aborts the hook rather than running it with a
58+
missing value.
59+
4660
### Environment detection
4761

4862
**Vortex** automatically detects when running on Acquia and loads appropriate

‎.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/copy-db.sh‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#
55
# Environment variables must be set in Acquia UI globally or for each environment.
66

7-
set -e
7+
set -eu
88
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
99

10-
site="${1}"
11-
target_env="${2}"
10+
site="${1:?Missing required site name.}"
11+
target_env="${2:?Missing required target environment name.}"
1212

13-
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
14-
15-
[ "${VORTEX_TASK_COPY_DB_ACQUIA_SKIP}" = "1" ] && echo "Skipping copying of database between Acquia environments." && exit 0
13+
[ "${VORTEX_TASK_COPY_DB_ACQUIA_SKIP:-}" = "1" ] && echo "Skipping copying of database between Acquia environments." && exit 0
1614

1715
export VORTEX_PLATFORM=acquia
18-
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY?not set}"
19-
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET?not set}"
16+
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY:?Missing required value.}"
17+
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET:?Missing required value.}"
2018
export VORTEX_ACQUIA_APP_NAME="${VORTEX_ACQUIA_APP_NAME:-${site}}"
2119
export VORTEX_TASK_COPY_DB_ACQUIA_SRC="${VORTEX_TASK_COPY_DB_ACQUIA_SRC:-prod}"
2220
export VORTEX_TASK_COPY_DB_ACQUIA_DST="${VORTEX_TASK_COPY_DB_ACQUIA_DST:-${target_env}}"
23-
export VORTEX_TASK_COPY_DB_ACQUIA_NAME="${VORTEX_TASK_COPY_DB_ACQUIA_NAME?not set}"
21+
export VORTEX_TASK_COPY_DB_ACQUIA_NAME="${VORTEX_TASK_COPY_DB_ACQUIA_NAME:?Missing required value.}"
22+
23+
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
2424

2525
./vendor/bin/vortex-task copy-db
2626

‎.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/copy-files.sh‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#
55
# Environment variables must be set in Acquia UI globally or for each environment.
66

7-
set -e
7+
set -eu
88
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
99

10-
site="${1}"
11-
target_env="${2}"
10+
site="${1:?Missing required site name.}"
11+
target_env="${2:?Missing required target environment name.}"
1212

13-
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
14-
15-
[ "${VORTEX_TASK_COPY_FILES_ACQUIA_SKIP}" = "1" ] && echo "Skipping copying of files between Acquia environments." && exit 0
13+
[ "${VORTEX_TASK_COPY_FILES_ACQUIA_SKIP:-}" = "1" ] && echo "Skipping copying of files between Acquia environments." && exit 0
1614

1715
export VORTEX_PLATFORM=acquia
18-
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY?not set}"
19-
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET?not set}"
16+
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY:?Missing required value.}"
17+
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET:?Missing required value.}"
2018
export VORTEX_ACQUIA_APP_NAME="${VORTEX_ACQUIA_APP_NAME:-${site}}"
2119
export VORTEX_TASK_COPY_FILES_ACQUIA_SRC="${VORTEX_TASK_COPY_FILES_ACQUIA_SRC:-prod}"
2220
export VORTEX_TASK_COPY_FILES_ACQUIA_DST="${VORTEX_TASK_COPY_FILES_ACQUIA_DST:-${target_env}}"
2321

22+
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
23+
2424
./vendor/bin/vortex-task copy-files
2525

2626
popd >/dev/null || exit 1

‎.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/notify-deployment.sh‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# Acquia Cloud hook: Send deployment notifications.
44
#
55

6-
set -e
6+
set -eu
77
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
88

9-
site="${1}"
10-
target_env="${2}"
11-
branch="${3}"
12-
ref="${4}"
9+
site="${1:?Missing required site name.}"
10+
target_env="${2:?Missing required target environment name.}"
11+
branch="${3:?Missing required branch name.}"
12+
ref="${4:?Missing required commit reference.}"
13+
14+
[ "${VORTEX_NOTIFY_ACQUIA_SKIP:-}" = "1" ] && echo "Skipping sending of deployment notifications in Acquia environment." && exit 0
1315

1416
# Custom domain name for the environment, including subdomain.
1517
# Examples: "dev.example.com", "test.example.com", "www.example.com"
1618
VORTEX_NOTIFY_ENVIRONMENT_DOMAIN="${VORTEX_NOTIFY_ENVIRONMENT_DOMAIN:-}"
1719

18-
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
19-
20-
url="https://${AH_SITE_NAME}.${AH_REALM:-prod}.acquia-sites.com"
21-
2220
if [ -n "${VORTEX_NOTIFY_ENVIRONMENT_DOMAIN}" ]; then
2321
url="https://${VORTEX_NOTIFY_ENVIRONMENT_DOMAIN}"
22+
else
23+
url="https://${AH_SITE_NAME:?Missing required value.}.${AH_REALM:-prod}.acquia-sites.com"
2424
fi
2525

2626
export VORTEX_NOTIFY_PROJECT="${site}"
@@ -30,6 +30,8 @@ export VORTEX_NOTIFY_PR_NUMBER=""
3030
export VORTEX_NOTIFY_LABEL="${branch}"
3131
export VORTEX_NOTIFY_ENVIRONMENT_URL="${url}"
3232

33+
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
34+
3335
./vendor/bin/vortex-notify
3436

3537
popd >/dev/null || exit 1

‎.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/provision.sh‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
# Acquia Cloud hook: Provision site.
44
#
55

6-
set -e
6+
set -eu
77
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
88

9-
site="${1}"
10-
target_env="${2}"
9+
site="${1:?Missing required site name.}"
10+
target_env="${2:?Missing required target environment name.}"
11+
12+
[ "${VORTEX_PROVISION_ACQUIA_SKIP:-}" = "1" ] && echo "Skipping provisioning of the site in Acquia environment." && exit 0
1113

1214
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
1315

‎.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/purge-cache.sh‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
#
55
# Environment variables must be set in Acquia UI globally or for each environment.
66

7-
set -e
7+
set -eu
88
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
99

10-
site="${1}"
11-
target_env="${2}"
10+
site="${1:?Missing required site name.}"
11+
target_env="${2:?Missing required target environment name.}"
1212

13-
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
14-
15-
[ "${VORTEX_PURGE_CACHE_ACQUIA_SKIP}" = "1" ] && echo "Skipping purging of cache in Acquia environment." && exit 0
13+
[ "${VORTEX_PURGE_CACHE_ACQUIA_SKIP:-}" = "1" ] && echo "Skipping purging of cache in Acquia environment." && exit 0
1614

1715
export VORTEX_PLATFORM=acquia
18-
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY?not set}"
19-
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET?not set}"
16+
export VORTEX_ACQUIA_KEY="${VORTEX_ACQUIA_KEY:?Missing required value.}"
17+
export VORTEX_ACQUIA_SECRET="${VORTEX_ACQUIA_SECRET:?Missing required value.}"
2018
export VORTEX_ACQUIA_APP_NAME="${VORTEX_ACQUIA_APP_NAME:-${site}}"
2119
export VORTEX_TASK_PURGE_CACHE_ACQUIA_ENV="${VORTEX_TASK_PURGE_CACHE_ACQUIA_ENV:-${target_env}}"
2220
export VORTEX_TASK_PURGE_CACHE_ACQUIA_DOMAINS_FILE="${VORTEX_TASK_PURGE_CACHE_ACQUIA_DOMAINS_FILE:-"/var/www/html/${site}.${target_env}/hooks/library/domains.txt"}"
2321

22+
pushd "/var/www/html/${site}.${target_env}" >/dev/null || exit 1
23+
2424
./vendor/bin/vortex-task purge-cache
2525

2626
popd >/dev/null || exit 1

0 commit comments

Comments
 (0)