Skip to content

Commit b7a1c01

Browse files
Update configuration
1 parent 6096558 commit b7a1c01

2 files changed

Lines changed: 55 additions & 46 deletions

File tree

composer.lock

Lines changed: 33 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/sites/default/settings.php

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
ini_set('zend.enable_gc', 'Off');
1313
}
1414

15+
$env = getenv('APP_ENV');
1516

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

156157
// Make sure project name and app env are defined in GitHub actions too.
157158
if ($github_repository = getenv('GITHUB_REPOSITORY')) {
158-
if (!getenv('APP_ENV')) {
159+
if (!$env) {
159160
putenv('APP_ENV=ci');
160161
}
161162

162163
if (!getenv('PROJECT_NAME')) {
163164
putenv('PROJECT_NAME=' . $github_repository);
164165
}
165166
}
166-
$config['helfi_api_base.environment_resolver.settings']['environment_name'] = getenv('APP_ENV');
167+
$config['helfi_api_base.environment_resolver.settings']['environment_name'] = $env;
167168
$config['helfi_api_base.environment_resolver.settings']['project_name'] = getenv('PROJECT_NAME');
168169

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

173174
$varnish_backend = parse_url($drush_options_uri, PHP_URL_HOST);
174175

175-
if (getenv('APP_ENV') === 'local') {
176+
if ($env === 'local') {
176177
// Varnish backend is something like varnish-helfi-kymp.docker.so on
177178
// local env.
178179
$varnish_backend = 'varnish-' . $varnish_backend;
@@ -227,15 +228,6 @@ function drupal_get_env(string|array $variables) : mixed {
227228
}
228229
}
229230
}
230-
$stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN');
231-
$stage_file_proxy_dir = getenv('STAGE_FILE_PROXY_ORIGIN_DIR');
232-
233-
if ($stage_file_proxy_origin || $stage_file_proxy_dir) {
234-
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin ?: 'https://stplattaprod.blob.core.windows.net';
235-
$config['stage_file_proxy.settings']['origin_dir'] = $stage_file_proxy_dir;
236-
$config['stage_file_proxy.settings']['hotlink'] = FALSE;
237-
$config['stage_file_proxy.settings']['use_imagecache_root'] = FALSE;
238-
}
239231

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

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

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

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

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

381+
if ($env !== 'production') {
382+
$stage_file_proxy_origin = getenv('STAGE_FILE_PROXY_ORIGIN');
383+
$stage_file_proxy_dir = getenv('STAGE_FILE_PROXY_ORIGIN_DIR');
384+
385+
// Always default to blob storage if configured.
386+
if ($blob_storage_container = getenv('AZURE_BLOB_STORAGE_CONTAINER')) {
387+
$stage_file_proxy_origin = 'https://stplattaprod.blob.core.windows.net';
388+
$stage_file_proxy_dir = $blob_storage_container;
389+
}
390+
$config['stage_file_proxy.settings']['origin'] = $stage_file_proxy_origin;
391+
$config['stage_file_proxy.settings']['origin_dir'] = $stage_file_proxy_dir;
392+
$config['stage_file_proxy.settings']['hotlink'] = FALSE;
393+
$config['stage_file_proxy.settings']['use_imagecache_root'] = TRUE;
394+
}
395+
389396
// Environment specific overrides.
390397
if (file_exists(__DIR__ . '/all.settings.php')) {
391398
// phpcs:ignore
392399
include_once __DIR__ . '/all.settings.php'; // NOSONAR
393400
}
394401

395-
if ($env = getenv('APP_ENV')) {
402+
if ($env) {
396403
if (file_exists(__DIR__ . '/' . $env . '.settings.php')) {
397404
// phpcs:ignore
398405
include_once __DIR__ . '/' . $env . '.settings.php'; // NOSONAR

0 commit comments

Comments
 (0)