diff --git a/.scaffold/tests/bats/_helper.bash b/.scaffold/tests/bats/_helper.bash index 84b1445dd..c5835a935 100644 --- a/.scaffold/tests/bats/_helper.bash +++ b/.scaffold/tests/bats/_helper.bash @@ -729,7 +729,7 @@ assert_files_present_integration_acquia() { assert_symlink_exists "hooks/prod/post-code-update" assert_symlink_not_exists "hooks/prod/post-db-copy" - assert_file_contains "${webroot}/sites/default/settings.php" "if (file_exists('/var/www/site-php" + assert_file_exists "${webroot}/sites/default/includes/providers/settings.acquia.php" assert_file_contains "${webroot}/.htaccess" "RewriteCond %{ENV:AH_SITE_ENVIRONMENT} prod [NC]" if [ "${include_scripts:-}" -eq 1 ]; then @@ -751,7 +751,7 @@ assert_files_present_no_integration_acquia() { assert_dir_not_exists "hooks" assert_dir_not_exists "hooks/library" - assert_file_not_contains "${webroot}/sites/default/settings.php" "if (file_exists('/var/www/site-php')) {" + assert_file_not_exists "${webroot}sites/default/includes/providers/settings.acquia.php" assert_file_not_contains "${webroot}/.htaccess" "RewriteCond %{ENV:AH_SITE_ENVIRONMENT} prod [NC]" assert_file_not_contains ".env" "DREVOPS_ACQUIA_APP_NAME=" assert_file_not_contains ".env" "DREVOPS_DB_DOWNLOAD_ACQUIA_DB_NAME=" @@ -770,6 +770,7 @@ assert_files_present_integration_lagoon() { pushd "${dir}" >/dev/null || exit 1 + assert_file_exists "${webroot}/sites/default/includes/providers/settings.lagoon.php" assert_file_exists ".lagoon.yml" assert_file_exists "drush/sites/lagoon.site.yml" assert_file_exists ".github/workflows/close-pull-request.yml" @@ -793,6 +794,7 @@ assert_files_present_no_integration_lagoon() { pushd "${dir}" >/dev/null || exit 1 + assert_file_not_exists "${webroot}/sites/default/includes/providers/settings.lagoon.php" assert_file_not_exists ".lagoon.yml" assert_file_not_exists "drush/sites/lagoon.site.yml" assert_file_not_exists ".github/workflows/close-pull-request.yml" diff --git a/web/sites/default/includes/settings.clamav.php b/web/sites/default/includes/modules/settings.clamav.php similarity index 100% rename from web/sites/default/includes/settings.clamav.php rename to web/sites/default/includes/modules/settings.clamav.php diff --git a/web/sites/default/includes/settings.config_split.php b/web/sites/default/includes/modules/settings.config_split.php similarity index 100% rename from web/sites/default/includes/settings.config_split.php rename to web/sites/default/includes/modules/settings.config_split.php diff --git a/web/sites/default/includes/settings.environment_indicator.php b/web/sites/default/includes/modules/settings.environment_indicator.php similarity index 100% rename from web/sites/default/includes/settings.environment_indicator.php rename to web/sites/default/includes/modules/settings.environment_indicator.php diff --git a/web/sites/default/includes/settings.fast404.php b/web/sites/default/includes/modules/settings.fast404.php similarity index 100% rename from web/sites/default/includes/settings.fast404.php rename to web/sites/default/includes/modules/settings.fast404.php diff --git a/web/sites/default/includes/settings.redis.php b/web/sites/default/includes/modules/settings.redis.php similarity index 100% rename from web/sites/default/includes/settings.redis.php rename to web/sites/default/includes/modules/settings.redis.php diff --git a/web/sites/default/includes/settings.shield.php b/web/sites/default/includes/modules/settings.shield.php similarity index 100% rename from web/sites/default/includes/settings.shield.php rename to web/sites/default/includes/modules/settings.shield.php diff --git a/web/sites/default/includes/settings.stage_file_proxy.php b/web/sites/default/includes/modules/settings.stage_file_proxy.php similarity index 100% rename from web/sites/default/includes/settings.stage_file_proxy.php rename to web/sites/default/includes/modules/settings.stage_file_proxy.php diff --git a/web/sites/default/includes/providers/settings.acquia.php b/web/sites/default/includes/providers/settings.acquia.php new file mode 100644 index 000000000..5bcf4cdb8 --- /dev/null +++ b/web/sites/default/includes/providers/settings.acquia.php @@ -0,0 +1,38 @@ + ACQUIA - -// #;< LAGOON -// Initialise environment type in Lagoon environment. -if (getenv('LAGOON') && getenv('LAGOON_ENVIRONMENT_TYPE') == 'production' || getenv('LAGOON_ENVIRONMENT_TYPE') == 'development') { - // Do not put any Lagoon-specific settings in this code block. It is used - // to explicitly map Lagoon environments to $settings['environment'] - // variable only. - // Instead, use 'PER-ENVIRONMENT SETTINGS' section below. - // - // Environment is marked as 'production' in Lagoon. - if (getenv('LAGOON_ENVIRONMENT_TYPE') == 'production') { - $settings['environment'] = ENVIRONMENT_PROD; - } - // All other environments running in Lagoon are considered 'development'. - else { - // Any other environment is considered 'development' in Lagoon. - $settings['environment'] = ENVIRONMENT_DEV; - - // But try to identify production environment using a branch name for - // the cases when 'production' Lagoon environment is not provisioned yet. - if (!empty(getenv('LAGOON_GIT_BRANCH')) && !empty(getenv('DREVOPS_LAGOON_PRODUCTION_BRANCH')) && getenv('LAGOON_GIT_BRANCH') === getenv('DREVOPS_LAGOON_PRODUCTION_BRANCH')) { - $settings['environment'] = ENVIRONMENT_PROD; - } - // Dedicated test environment based on a branch name. - elseif (getenv('LAGOON_GIT_BRANCH') == 'master') { - $settings['environment'] = ENVIRONMENT_TEST; - } - // Test environment based on a branch prefix for release and - // hotfix branches. - elseif (!empty(getenv('LAGOON_GIT_BRANCH')) && (str_starts_with(getenv('LAGOON_GIT_BRANCH'), 'release/') || str_starts_with(getenv('LAGOON_GIT_BRANCH'), 'hotfix/'))) { - $settings['environment'] = ENVIRONMENT_TEST; +// Load environment-specific settings. +if (file_exists($app_root . '/' . $site_path . '/includes/providers')) { + $files = glob($app_root . '/' . $site_path . '/includes/providers/settings.*.php'); + if ($files) { + foreach ($files as $filename) { + require $filename; } } - - // Lagoon version. - if (!defined('LAGOON_VERSION')) { - define('LAGOON_VERSION', '1'); - } - - // Lagoon reverse proxy settings. - $settings['reverse_proxy'] = TRUE; - // Reverse proxy settings. - $settings['reverse_proxy_header'] = 'HTTP_TRUE_CLIENT_IP'; - - // Cache prefix. - $settings['cache_prefix']['default'] = (getenv('LAGOON_PROJECT') ?: getenv('DREVOPS_PROJECT')) . '_' . (getenv('LAGOON_GIT_SAFE_BRANCH') ?: getenv('DREVOPS_LAGOON_PRODUCTION_BRANCH')); - - // Trusted host patterns for Lagoon internal routes. - // URL when accessed from PHP processes in Lagoon. - $settings['trusted_host_patterns'][] = '^nginx\-php$'; - // Lagoon URL. - $settings['trusted_host_patterns'][] = '^.+\.au\.amazee\.io$'; - // Lagoon routes. - if (getenv('LAGOON_ROUTES')) { - $patterns = str_replace(['.', 'https://', 'http://', ','], [ - '\.', '', '', '|', - ], getenv('LAGOON_ROUTES')); - $settings['trusted_host_patterns'][] = '^' . $patterns . '$'; - } } -// #;> LAGOON // Allow overriding of an environment type. if (!empty(getenv('DRUPAL_ENVIRONMENT'))) { @@ -226,7 +143,7 @@ } //////////////////////////////////////////////////////////////////////////////// -/// ENVIRONMENT DETECTION /// +/// ENVIRONMENT-SPECIFIC SETTINGS /// //////////////////////////////////////////////////////////////////////////////// if ($settings['environment'] == ENVIRONMENT_CI) { @@ -255,8 +172,8 @@ /// PER-MODULE SETTINGS /// //////////////////////////////////////////////////////////////////////////////// -if (file_exists($app_root . '/' . $site_path . '/includes')) { - $files = glob($app_root . '/' . $site_path . '/includes/settings.*.php'); +if (file_exists($app_root . '/' . $site_path . '/includes/modules')) { + $files = glob($app_root . '/' . $site_path . '/includes/modules/settings.*.php'); if ($files) { foreach ($files as $filename) { require $filename;