From ff996c1b23ae115a88bd01a49c80aec73483508d Mon Sep 17 00:00:00 2001 From: Chris Bellas Date: Tue, 31 Aug 2021 12:11:46 +0300 Subject: [PATCH] Changed env calls to config --- api/.env.example | 2 ++ api/app/Http/Controllers/ConfigController.php | 20 +++++++++++++------- api/config/kea.php | 21 +++++++++++++++++++++ api/config/keycloak.php | 3 +++ 4 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 api/config/kea.php diff --git a/api/.env.example b/api/.env.example index 6932177..5572cca 100644 --- a/api/.env.example +++ b/api/.env.example @@ -54,8 +54,10 @@ KEYCLOAK_REALM=Integration KEYCLOAK_URL=https://keycloak-curex.gnubila.fr/auth/ KEYCLOAK_CLIENT_ID=KEA +# url must be without trailing / KIBANA_URL=$APP_URL GRAFANA_URL=$APP_URL +# set ports null to ignore KIBANA_PORT=5611 GRAFANA_PORT=3001 diff --git a/api/app/Http/Controllers/ConfigController.php b/api/app/Http/Controllers/ConfigController.php index db33343..0238281 100644 --- a/api/app/Http/Controllers/ConfigController.php +++ b/api/app/Http/Controllers/ConfigController.php @@ -9,19 +9,25 @@ class ConfigController extends Controller public function index(Request $request) { return [ - 'base_url' => env('APP_URL'), - 'od_url' => env('GRAFANA_URL'), - 'mltd_url' => env('GRAFANA_URL'), - 'ceptd_url' => env('KIBANA_URL') + 'base_url' => config('app.url'), + 'od_url' => config('kea.grafana.url') . + (config('kea.grafana.port') ? ':' . config('kea.grafana.port') : '') + . config('kea.grafana.od_params'), + 'mltd_url' => config('kea.grafana.url') . + (config('kea.grafana.port') ? ':' . config('kea.grafana.port') : '') + . config('kea.grafana.mltd_params'), + 'ceptd_url' => config('kea.kibana.url') . + (config('kea.kibana.port') ? ':' . config('kea.kibana.port') : '') + . config('kea.kibana.ceptd_params'), ]; } public function keycloak(Request $request) { return [ - 'realm' => env('KEYCLOAK_REALM'), - 'url' => env('KEYCLOAK_URL'), - 'clientId' => env('KEYCLOAK_CLIENT_ID'), + 'realm' => config('keycloak.realm'), + 'url' => config('keycloak.url'), + 'clientId' => config('keycloak.client_id'), ]; } } diff --git a/api/config/kea.php b/api/config/kea.php new file mode 100644 index 0000000..d652e0c --- /dev/null +++ b/api/config/kea.php @@ -0,0 +1,21 @@ + env('AUTH_ENABLED', false), + + 'kibana' => [ + 'url' => env('KIBANA_URL', null), + 'port' => env('KIBANA_PORT', null), + 'ceptd_params' => env('CEPTD_KIBANA_PARAMS', null), + ], + + 'grafana' => [ + 'url' => env('GRAFANA_URL', null), + 'port' => env('GRAFANA_PORT', null), + 'od_params' => env('OD_GRAFANA_PARAMS', null), + 'mltd_params' => env('MLTD_GRAFANA_PARAMS', null), + ], + + 'remote_syslog' => env('REMOTESYSLOG', null), +]; diff --git a/api/config/keycloak.php b/api/config/keycloak.php index aae9f56..f410ae2 100644 --- a/api/config/keycloak.php +++ b/api/config/keycloak.php @@ -1,6 +1,9 @@ env('KEYCLOAK_REALM', null), + 'url' => env('KEYCLOAK_URL', null), + 'client_id' => env('KEYCLOAK_CLIENT_ID', null), 'realm_public_key' => env('KEYCLOAK_REALM_PUBLIC_KEY', null), 'load_user_from_database' => env('KEYCLOAK_LOAD_USER_FROM_DATABASE', false), 'user_provider_credential' => env('KEYCLOAK_USER_PROVIDER_CREDENTIAL', 'username'), -- 2.2.2