Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions public/sites/default/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
ini_set('zend.enable_gc', 'Off');
}

$env = getenv('APP_ENV');

if (!function_exists('drupal_get_env')) {
/**
Expand Down Expand Up @@ -155,15 +156,15 @@ function drupal_get_env(string|array $variables) : mixed {

// Make sure project name and app env are defined in GitHub actions too.
if ($github_repository = getenv('GITHUB_REPOSITORY')) {
if (!getenv('APP_ENV')) {
if (!$env) {
putenv('APP_ENV=ci');
}

if (!getenv('PROJECT_NAME')) {
putenv('PROJECT_NAME=' . $github_repository);
}
}
$config['helfi_api_base.environment_resolver.settings']['environment_name'] = getenv('APP_ENV');
$config['helfi_api_base.environment_resolver.settings']['environment_name'] = $env;
$config['helfi_api_base.environment_resolver.settings']['project_name'] = getenv('PROJECT_NAME');

if ($varnish_host = getenv('DRUPAL_VARNISH_HOST')) {
Expand All @@ -172,7 +173,7 @@ function drupal_get_env(string|array $variables) : mixed {

$varnish_backend = parse_url($drush_options_uri, PHP_URL_HOST);

if (getenv('APP_ENV') === 'local') {
if ($env === 'local') {
// Varnish backend is something like varnish-helfi-kymp.docker.so on
// local env.
$varnish_backend = 'varnish-' . $varnish_backend;
Expand Down Expand Up @@ -227,15 +228,6 @@ function drupal_get_env(string|array $variables) : mixed {
}
}
}
$stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN');
$stage_file_proxy_dir = getenv('STAGE_FILE_PROXY_ORIGIN_DIR');

if ($stage_file_proxy_origin || $stage_file_proxy_dir) {
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin ?: 'https://stplattaprod.blob.core.windows.net';
$config['stage_file_proxy.settings']['origin_dir'] = $stage_file_proxy_dir;
$config['stage_file_proxy.settings']['hotlink'] = FALSE;
$config['stage_file_proxy.settings']['use_imagecache_root'] = FALSE;
}

if ($drupal_pubsub_vault = getenv('DRUPAL_PUBSUB_VAULT')) {
$config['helfi_api_base.api_accounts']['vault'][] = [
Expand Down Expand Up @@ -343,7 +335,7 @@ function drupal_get_env(string|array $variables) : mixed {
}

// Supported values: https://github.com/Seldaek/monolog/blob/main/doc/01-usage.md#log-levels.
$default_log_level = getenv('APP_ENV') === 'production' ? 'info' : 'debug';
$default_log_level = $env === 'production' ? 'info' : 'debug';
$settings['helfi_api_base.log_level'] = getenv('LOG_LEVEL') ?: $default_log_level;

// Turn sentry JS error tracking on if SENTRY_DSN_PUBLIC is defined.
Expand Down Expand Up @@ -373,7 +365,7 @@ function drupal_get_env(string|array $variables) : mixed {

// E2E test users. We should never do this in production, so adding a failsafe
// in case the environment variable would ever end up in production.
if (getenv('APP_ENV') !== 'production' && $e2e_test_user = getenv('E2E_TEST_USER')) {
if ($env !== 'production' && $e2e_test_user = getenv('E2E_TEST_USER')) {
$e2e_test_user = json_decode($e2e_test_user, TRUE);

// Make sure the user exists in Drupal.
Expand All @@ -386,13 +378,28 @@ function drupal_get_env(string|array $variables) : mixed {
]);
}

if ($env !== 'production') {
$stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN');
$stage_file_proxy_dir = getenv('STAGE_FILE_PROXY_ORIGIN_DIR');

// Always default to blob storage if configured.
if ($blob_storage_container = getenv('AZURE_BLOB_STORAGE_CONTAINER')) {
$stage_file_proxy_origin = 'https://stplattaprod.blob.core.windows.net';
$stage_file_proxy_dir = $blob_storage_container;
}
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin;
$config['stage_file_proxy.settings']['origin_dir'] = $stage_file_proxy_dir;
$config['stage_file_proxy.settings']['hotlink'] = FALSE;
$config['stage_file_proxy.settings']['use_imagecache_root'] = TRUE;
}

// Environment specific overrides.
if (file_exists(__DIR__ . '/all.settings.php')) {
// phpcs:ignore
include_once __DIR__ . '/all.settings.php'; // NOSONAR
}

if ($env = getenv('APP_ENV')) {
if ($env) {
if (file_exists(__DIR__ . '/' . $env . '.settings.php')) {
// phpcs:ignore
include_once __DIR__ . '/' . $env . '.settings.php'; // NOSONAR
Expand Down