From 13799fa2003684c48a1d9d01765e1908ddd10e49 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Thu, 29 Jul 2021 16:54:47 +0200
Subject: [PATCH] Stop using the APP_ prefix for custom env vars

It's used by symfony, use API_ instead
---
 .env                          | 7 ++-----
 .gitlab-ci/deploy.php         | 8 ++++----
 config/packages/dbp_core.yaml | 4 ++--
 src/Kernel.php                | 2 +-
 4 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/.env b/.env
index 78e5fc7..d0485c1 100644
--- a/.env
+++ b/.env
@@ -30,8 +30,5 @@ KEYCLOAK_CLIENT_ID=
 KEYCLOAK_CLIENT_SECRET=
 
 # Deployment related
-APP_BUILDINFO=unknown  # a git hash or something identifying the build
-APP_BUILDINFO_URL='#'
-
-# Defines the deployment environment
-APP_DEPLOYMENT_ENV='local'
+API_BUILDINFO=unknown  # a git hash or something identifying the build
+API_BUILDINFO_URL='#'
diff --git a/.gitlab-ci/deploy.php b/.gitlab-ci/deploy.php
index 32342fe..d2f4128 100644
--- a/.gitlab-ci/deploy.php
+++ b/.gitlab-ci/deploy.php
@@ -35,7 +35,7 @@ host('development')
     ->set('shared_dirs', ['var/log', 'var/sessions'])
     ->set('APP_ENV', 'prod')
     ->set('APP_DEBUG', '0')
-    ->set('APP_DEPLOYMENT_ENV', 'development')
+    ->set('API_DEPLOYMENT_ENV', 'development')
     ->set('KEYCLOAK_SERVER_URL', 'https://auth-dev.tugraz.at/auth')
     ->set('KEYCLOAK_CLIENT_ID', 'auth-dev-mw-dev')
     ->set('KEYCLOAK_FRONTEND_CLIENT_ID', 'auth-dev-mw-frontend')
@@ -52,7 +52,7 @@ task('build-custom', function () {
         'KEYCLOAK_CLIENT_SECRET' => getenv('KEYCLOAK_CLIENT_SECRET'),
         'APP_ENV' => $APP_ENV,
         'APP_DEBUG' => get('APP_DEBUG'),
-        'APP_DEPLOYMENT_ENV' => get('APP_DEPLOYMENT_ENV'),
+        'API_DEPLOYMENT_ENV' => get('API_DEPLOYMENT_ENV'),
         'KEYCLOAK_SERVER_URL' => get('KEYCLOAK_SERVER_URL'),
         'KEYCLOAK_CLIENT_ID' => get('KEYCLOAK_CLIENT_ID'),
         'KEYCLOAK_FRONTEND_CLIENT_ID' => get('KEYCLOAK_FRONTEND_CLIENT_ID'),
@@ -69,7 +69,7 @@ task('build-custom', function () {
 
     // Add build commit
     $commit = runLocally('git rev-parse --short HEAD');
-    runLocally("echo \"APP_BUILDINFO=${commit}\" >> .env.local");
+    runLocally("echo \"API_BUILDINFO=${commit}\" >> .env.local");
 
     // Add commit url to gitlab
     $remote = runLocally('git config --get remote.origin.url');
@@ -77,7 +77,7 @@ task('build-custom', function () {
     $parts['path'] = substr($parts['path'], 0, (strrpos($parts['path'], '.')));
     $base_url = $parts['scheme'].'://'.$parts['host'].$parts['path'];
     $build_url = $base_url.'/'.rawurlencode('commit').'/'.rawurlencode($commit);
-    runLocally("echo \"APP_BUILDINFO_URL=${build_url}\" >> .env.local");
+    runLocally("echo \"API_BUILDINFO_URL=${build_url}\" >> .env.local");
 
     // composer install and optimize
     runLocally('composer install --no-dev --classmap-authoritative');
diff --git a/config/packages/dbp_core.yaml b/config/packages/dbp_core.yaml
index 6ba731a..5182104 100644
--- a/config/packages/dbp_core.yaml
+++ b/config/packages/dbp_core.yaml
@@ -1,3 +1,3 @@
 dbp_core:
-    build_info: '%env(APP_BUILDINFO)%'
-    build_info_url: '%env(APP_BUILDINFO_URL)%'
+    build_info: '%env(API_BUILDINFO)%'
+    build_info_url: '%env(API_BUILDINFO_URL)%'
diff --git a/src/Kernel.php b/src/Kernel.php
index 1213710..f053015 100644
--- a/src/Kernel.php
+++ b/src/Kernel.php
@@ -17,7 +17,7 @@ class Kernel extends BaseKernel
     {
         // Ignore all errors in case we are not local/development. We disable some
         // bundles in demo/prod which leads to unused config, which symfony fails over.
-        $ignoreErrors = !in_array($_ENV['APP_DEPLOYMENT_ENV'], ['local', 'development'], true);
+        $ignoreErrors = !in_array($_ENV['API_DEPLOYMENT_ENV'], ['local', 'development'], true);
 
         $container->import('../config/{packages}/*.yaml', null, $ignoreErrors);
         $container->import('../config/{packages}/'.$this->environment.'/*.yaml');
-- 
GitLab