From c8cc0b0908e9f4f4e1a2114c3ffc5f770db02a36 Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Tue, 5 Mar 2024 16:54:08 +0100 Subject: [PATCH] handled environment variables to be consistent --- README.md | 2 +- app-config/calculator-app/app.sh | 3 ++- app-config/docker-compose.yml | 6 ++++-- app-config/openshift/deploymentconfig.yaml | 8 ++++++-- caimira/apps/calculator/__init__.py | 5 ++--- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index a2684aed..e6f01033 100644 --- a/README.md +++ b/README.md @@ -361,7 +361,7 @@ $ oc create secret generic \ The CERN data service collects data from various sources and expose them via a REST API endpoint. -To enable the service set the environment variable `DATA_SERVICE_ENABLED` as `True`. +The service is enabled when the environment variable `DATA_SERVICE_ENABLED` is set to 1. ## Update configuration diff --git a/app-config/calculator-app/app.sh b/app-config/calculator-app/app.sh index 8292627b..505067b7 100755 --- a/app-config/calculator-app/app.sh +++ b/app-config/calculator-app/app.sh @@ -23,7 +23,8 @@ if [[ "$APP_NAME" == "calculator-app" ]]; then export "EXTRA_PAGES"="$EXTRA_PAGES" - export "DATA_SERVICE_ENABLED"="${DATA_SERVICE_ENABLED:=False}" + export "DATA_SERVICE_ENABLED"="${DATA_SERVICE_ENABLED:=0}" + export "CAIMIRA_PROFILER_ENABLED"="${CAIMIRA_PROFILER_ENABLED:=0}" echo "Starting the caimira webservice with: python -m caimira.apps.calculator ${args[@]}" python -m caimira.apps.calculator "${args[@]}" diff --git a/app-config/docker-compose.yml b/app-config/docker-compose.yml index 1be361b2..2d41dcc1 100644 --- a/app-config/docker-compose.yml +++ b/app-config/docker-compose.yml @@ -20,7 +20,8 @@ services: - APPLICATION_ROOT=/ - CAIMIRA_CALCULATOR_PREFIX=/calculator-cern - CAIMIRA_THEME=caimira/apps/templates/cern - - DATA_SERVICE_ENABLED=False + - DATA_SERVICE_ENABLED=0 + - CAIMIRA_PROFILER_ENABLED=0 user: ${CURRENT_UID} calculator-open-app: @@ -30,7 +31,8 @@ services: - APP_NAME=calculator-app - APPLICATION_ROOT=/ - CAIMIRA_CALCULATOR_PREFIX=/calculator-open - - DATA_SERVICE_ENABLED=False + - DATA_SERVICE_ENABLED=0 + - CAIMIRA_PROFILER_ENABLED=0 user: ${CURRENT_UID} auth-service: diff --git a/app-config/openshift/deploymentconfig.yaml b/app-config/openshift/deploymentconfig.yaml index ac58a1ea..638fb6b4 100644 --- a/app-config/openshift/deploymentconfig.yaml +++ b/app-config/openshift/deploymentconfig.yaml @@ -284,7 +284,9 @@ key: ARVE_API_KEY name: arve-api - name: DATA_SERVICE_ENABLED - value: 'True' + value: '1' + - name: CAIMIRA_PROFILER_ENABLED + value: '1' image: '${PROJECT_NAME}/calculator-app' ports: - containerPort: 8080 @@ -363,7 +365,9 @@ - name: CAIMIRA_CALCULATOR_PREFIX value: /calculator-open - name: DATA_SERVICE_ENABLED - value: 'True' + value: '1' + - name: CAIMIRA_PROFILER_ENABLED + value: '1' image: '${PROJECT_NAME}/calculator-app' ports: - containerPort: 8080 diff --git a/caimira/apps/calculator/__init__.py b/caimira/apps/calculator/__init__.py index 8898f272..67de471c 100644 --- a/caimira/apps/calculator/__init__.py +++ b/caimira/apps/calculator/__init__.py @@ -563,9 +563,8 @@ def make_app( data_registry = DataRegistry() data_service = None - data_service_enabled = os.environ.get("DATA_SERVICE_ENABLED", "False") - is_enabled = data_service_enabled.lower() == "true" - if is_enabled: data_service = DataService.create() + data_service_enabled = os.environ.get('DATA_SERVICE_ENABLED', 0) + if data_service_enabled: data_service = DataService.create() return Application( urls,