From a9fb70fcc74578111b75f1004cef3e020ad9ce4a Mon Sep 17 00:00:00 2001 From: Jon Date: Sun, 16 Mar 2025 08:39:21 +0930 Subject: [PATCH] feat(devops): Add ability for user to turn off feature flagging check-in ref: #679 #496 --- app/app/settings.py | 18 ++++++++++++++++++ .../administration/devops/feature_flags.md | 9 +++++++++ includes/etc/itsm/settings.py | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/app/settings.py b/app/app/settings.py index e0a9d126..db38d61c 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -68,6 +68,7 @@ CELERY_WORKER_MAX_TASKS_PER_CHILD = 1 # worker_max_tasks_per_child CELERY_TASK_SEND_SENT_EVENT = True CELERY_WORKER_SEND_TASK_EVENTS = True # worker_send_task_events +FEATURE_FLAGGING_ENABLED = True # Turn Feature Flagging on/off # PROMETHEUS_METRICS_EXPORT_PORT_RANGE = range(8010, 8010) # PROMETHEUS_METRICS_EXPORT_PORT = 8010 @@ -472,3 +473,20 @@ is yours. If you do change the value ensure that it's still hashed as a sha256 h """ unique_id = str(f'{CELERY_BROKER_URL}{DOCS_ROOT}{SITE_URL}{SECRET_KEY}{feature_flag_version}') unique_id = hashlib.sha256(unique_id.encode()).hexdigest() + +if FEATURE_FLAGGING_ENABLED: + + FEATURE_FLAGGING_URL = 'https://alfred.nofusscomputing.com/api/v2/public/4/flags/1' + + if DEBUG: + + FEATURE_FLAGGING_URL = 'http://127.0.0.1:8002/api/v2/public/1/flags/2844' + + feature_flag = { + 'url': str(FEATURE_FLAGGING_URL), + 'user_agent': 'Centurion ERP', + 'cache_dir': str(BASE_DIR) + '/', + 'disable_downloading': False, + 'unique_id': unique_id, + 'version': feature_flag_version + } diff --git a/docs/projects/centurion_erp/administration/devops/feature_flags.md b/docs/projects/centurion_erp/administration/devops/feature_flags.md index 11df813e..e67900a3 100644 --- a/docs/projects/centurion_erp/administration/devops/feature_flags.md +++ b/docs/projects/centurion_erp/administration/devops/feature_flags.md @@ -22,3 +22,12 @@ It's completely your choice how you expose this endpoint although with the cavea - `HTTP/200 - Success` When the client checks-in and the feature flags have been supplied. If the user does not specify request header `If-Modified-Since:`, the feature flags will always be returned. + + +## Settings + +Within your settings file the following settings are available + +| Attribute | Type | Default | Description | +|:---|:---:|:---:|:---| +| FEATURE_FLAGGING_ENABLED | `Bolean` | `True `| Turn feature flagging on/off | diff --git a/includes/etc/itsm/settings.py b/includes/etc/itsm/settings.py index 7da37ce1..9a4d7f80 100644 --- a/includes/etc/itsm/settings.py +++ b/includes/etc/itsm/settings.py @@ -29,8 +29,10 @@ DATABASES = { # # CELERY_BROKER_URL = 'amqp://:@:/[]' # 'amqp://' is the connection protocol +FEATURE_FLAGGING_ENABLED = True # Turn Feature Flagging on/off + SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_SSL_REDIRECT = True -USE_X_FORWARDED_HOST = True +USE_X_FORWARDED_HOST = True