Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## April 1, 2026

- **Chore** Change trigger for environment detection in API [🎟️ DEP-242](https://citz-gdx.atlassian.net/browse/DEP-242)
- Updated Helm templates to set a new environment variable `ENV` in the API deployment, which is then used by the API to determine the current environment (dev/test/prod).
- The env variable is loaded in config.py and is available as current_app.config['ENVIRONMENT'] for use in the API codebase.

## March 31, 2026

- **Chore** OpenShift and Helm value changes from MET to DEP [🎟️ DEP-231](https://citz-gdx.atlassian.net/browse/DEP-231)
Expand Down
12 changes: 9 additions & 3 deletions api/src/api/services/engagement_service.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Service for engagement management."""

import os
from datetime import datetime, timezone
from http import HTTPStatus
import os
from typing import Mapping, Optional, Sequence, Union

from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import selectinload
from flask import current_app
from flask import current_app, has_app_context
from flask_restx import abort
from marshmallow import ValidationError

Expand Down Expand Up @@ -550,7 +550,13 @@ def delete(cls, engagement_id: int):
one_of_roles = (Role.SUPER_ADMIN.value, Role.UNPUBLISH_ENGAGEMENT.value)
authorization.check_auth(one_of_roles=one_of_roles)

current_env = os.getenv('FLASK_ENV', 'production').lower()
current_env = (
(current_app.config.get('ENVIRONMENT') if has_app_context() else '') or
os.getenv('ENVIRONMENT') or
os.getenv('DEPLOYMENT_ENV') or
os.getenv('FLASK_ENV', 'development')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we default to production for FLASK_ENV since production has higher security?

).strip().lower()

if current_env in ('prod', 'production'):
abort(HTTPStatus.FORBIDDEN, 'Cannot delete an engagement in production environment')

Expand Down
3 changes: 2 additions & 1 deletion notify-api/src/notify_api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_named_config(config_name: str = 'production'):

:raise: KeyError: if an unknown configuration is requested
"""
if config_name in ['production', 'staging', 'default']:
if config_name in ['production', 'prod', 'staging', 'default']:
config = ProdConfig()
elif config_name == 'testing':
config = TestConfig()
Expand All @@ -54,6 +54,7 @@ class _Config(): # pylint: disable=too-few-public-methods
"""Base class configuration that should set reasonable defaults for all the other configurations."""

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
ENVIRONMENT = os.getenv('ENV', 'production')

# GC Notify
GC_NOTIFY_API_KEY = os.getenv('GC_NOTIFY_API_KEY')
Expand Down
1 change: 1 addition & 0 deletions openshift/api/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
app-group: engagement-app
data:
# Engagement API configuration
ENV: {{ .Values.environment | quote }}
CORS_ORIGINS: {{ .Values.site.url }}
DEFAULT_TENANT_SHORT_NAME: {{ .Values.tenant.shortName }}
ACCESS_REQUEST_EMAIL_TEMPLATE_ID: {{ .Values.email.templateID.accessRequest }}
Expand Down
Loading