Skip to content
Snippets Groups Projects
Commit 11e163d4 authored by Calen Pennington's avatar Calen Pennington
Browse files

Read the current edx-platform git revision from a file on disk

parent 3fb00a40
Branches
Tags
No related merge requests found
......@@ -33,6 +33,7 @@ os.environ['CONFIG_ROOT'] = path(__file__).abspath().dirname()
os.environ['STUDIO_CFG'] = str.format("{config_root}/{service_variant}.yml",
config_root=os.environ['CONFIG_ROOT'],
service_variant=os.environ['SERVICE_VARIANT'])
os.environ['REVISION_CFG'] = "{config_root}/revisions.yml".format(config_root=os.environ['CONFIG_ROOT'])
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position
......
......@@ -45,6 +45,18 @@ with codecs.open(CONFIG_FILE, encoding='utf-8') as f:
AUTH_TOKENS = __config__
# 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')
try:
with codecs.open(REVISION_CONFIG_FILE, encoding='utf-8') as f:
REVISION_CONFIG = yaml.safe_load(f)
except Exception: # pylint: disable=broad-except
REVISION_CONFIG = {}
# Do NOT calculate this dynamically at startup with git because it's *slow*.
EDX_PLATFORM_REVISION = REVISION_CONFIG.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REVISION)
# SERVICE_VARIANT specifies name of the variant used, which decides what JSON
# configuration files are read during startup.
SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)
......@@ -110,9 +122,6 @@ CELERY_QUEUES = {
CELERY_ROUTES = "{}celery.Router".format(QUEUE_VARIANT)
# Do NOT calculate this dynamically at startup with git because it's *slow*.
EDX_PLATFORM_REVISION = ENV_TOKENS.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REVISION)
# STATIC_URL_BASE specifies the base url to use for static files
STATIC_URL_BASE = ENV_TOKENS.get('STATIC_URL_BASE', None)
if STATIC_URL_BASE:
......@@ -197,6 +206,9 @@ if 'loc_cache' not in CACHES:
'LOCATION': 'edx_location_mem_cache',
}
if 'staticfiles' in CACHES:
CACHES['staticfiles']['KEY_PREFIX'] = EDX_PLATFORM_REVISION
SESSION_COOKIE_DOMAIN = ENV_TOKENS.get('SESSION_COOKIE_DOMAIN')
SESSION_COOKIE_HTTPONLY = ENV_TOKENS.get('SESSION_COOKIE_HTTPONLY', True)
SESSION_ENGINE = ENV_TOKENS.get('SESSION_ENGINE', SESSION_ENGINE)
......
......@@ -36,6 +36,7 @@ os.environ['SERVICE_VARIANT'] = 'bok_choy_docker' if 'BOK_CHOY_HOSTNAME' in os.e
os.environ['CONFIG_ROOT'] = CONFIG_ROOT
os.environ['LMS_CFG'] = str.format("{config_root}/{service_variant}.yml",
config_root=os.environ['CONFIG_ROOT'], service_variant=os.environ['SERVICE_VARIANT'])
os.environ['REVISION_CFG'] = "{config_root}/revisions.yml".format(config_root=os.environ['CONFIG_ROOT'])
from .production import * # pylint: disable=wildcard-import, unused-wildcard-import, wrong-import-position
......
......@@ -56,6 +56,18 @@ with codecs.open(CONFIG_FILE, encoding='utf-8') as f:
ENV_TOKENS = __config__
AUTH_TOKENS = __config__
# 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')
try:
with codecs.open(REVISION_CONFIG_FILE, encoding='utf-8') as f:
REVISION_CONFIG = yaml.safe_load(f)
except Exception: # pylint: disable=broad-except
REVISION_CONFIG = {}
# Do NOT calculate this dynamically at startup with git because it's *slow*.
EDX_PLATFORM_REVISION = REVISION_CONFIG.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REVISION)
# SERVICE_VARIANT specifies name of the variant used, which decides what JSON
# configuration files are read during startup.
SERVICE_VARIANT = os.environ.get('SERVICE_VARIANT', None)
......@@ -230,6 +242,9 @@ if 'loc_cache' not in CACHES:
'LOCATION': 'edx_location_mem_cache',
}
if 'staticfiles' in CACHES:
CACHES['staticfiles']['KEY_PREFIX'] = EDX_PLATFORM_REVISION
# Email overrides
DEFAULT_FROM_EMAIL = ENV_TOKENS.get('DEFAULT_FROM_EMAIL', DEFAULT_FROM_EMAIL)
DEFAULT_FEEDBACK_EMAIL = ENV_TOKENS.get('DEFAULT_FEEDBACK_EMAIL', DEFAULT_FEEDBACK_EMAIL)
......@@ -1057,9 +1072,6 @@ PARENTAL_CONSENT_AGE_LIMIT = ENV_TOKENS.get(
PARENTAL_CONSENT_AGE_LIMIT
)
# Do NOT calculate this dynamically at startup with git because it's *slow*.
EDX_PLATFORM_REVISION = ENV_TOKENS.get('EDX_PLATFORM_REVISION', EDX_PLATFORM_REVISION)
########################## Extra middleware classes #######################
# Allow extra middleware classes to be added to the app through configuration.
......
......@@ -37,6 +37,7 @@ passenv =
EDX_PLATFORM_SETTINGS
JOB_NAME
LMS_CFG
REVISION_CFG
MOZ_HEADLESS
NODE_PATH
NODE_VIRTUAL_ENV
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment