Merge pull request #23052 from edx/feanil/production_py_autoload
Auto load any keys/values from the yaml config file.
This commit is contained in:
@@ -8,6 +8,7 @@ This is the default template for our main set of AWS servers.
|
||||
|
||||
|
||||
import codecs
|
||||
import copy
|
||||
import os
|
||||
import yaml
|
||||
|
||||
@@ -43,6 +44,25 @@ with codecs.open(CONFIG_FILE, encoding='utf-8') as f:
|
||||
ENV_TOKENS = __config__
|
||||
AUTH_TOKENS = __config__
|
||||
|
||||
# Add the key/values from config into the global namespace of this module.
|
||||
# But don't override the FEATURES dict because we do that in an additive way.
|
||||
__config_copy__ = copy.deepcopy(__config__)
|
||||
|
||||
KEYS_WITH_MERGED_VALUES = [
|
||||
'FEATURES',
|
||||
'TRACKING_BACKENDS',
|
||||
'EVENT_TRACKING_BACKENDS',
|
||||
'JWT_AUTH',
|
||||
'CELERY_QUEUES',
|
||||
'MKTG_URL_LINK_MAP',
|
||||
'MKTG_URL_OVERRIDES',
|
||||
]
|
||||
for key in KEYS_WITH_MERGED_VALUES:
|
||||
if key in __config_copy__:
|
||||
del __config_copy__[key]
|
||||
|
||||
vars().update(__config_copy__)
|
||||
|
||||
|
||||
# A file path to a YAML file from which to load all the code revisions currently deployed
|
||||
REVISION_CONFIG_FILE = get_env_setting('REVISION_CFG')
|
||||
|
||||
@@ -19,6 +19,7 @@ Common traits:
|
||||
|
||||
|
||||
import codecs
|
||||
import copy
|
||||
import datetime
|
||||
import os
|
||||
|
||||
@@ -55,6 +56,26 @@ with codecs.open(CONFIG_FILE, encoding='utf-8') as f:
|
||||
ENV_TOKENS = __config__
|
||||
AUTH_TOKENS = __config__
|
||||
|
||||
# Add the key/values from config into the global namespace of this module.
|
||||
# But don't override the FEATURES dict because we do that in an additive way.
|
||||
__config_copy__ = copy.deepcopy(__config__)
|
||||
|
||||
KEYS_WITH_MERGED_VALUES = [
|
||||
'FEATURES',
|
||||
'TRACKING_BACKENDS',
|
||||
'EVENT_TRACKING_BACKENDS',
|
||||
'JWT_AUTH',
|
||||
'CELERY_QUEUES',
|
||||
'MKTG_URL_LINK_MAP',
|
||||
'MKTG_URL_OVERRIDES',
|
||||
]
|
||||
for key in KEYS_WITH_MERGED_VALUES:
|
||||
if key in __config_copy__:
|
||||
del __config_copy__[key]
|
||||
|
||||
vars().update(__config_copy__)
|
||||
|
||||
|
||||
# A file path to a YAML file from which to load all the code revisions currently deployed
|
||||
REVISION_CONFIG_FILE = get_env_setting('REVISION_CFG')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user