Fix support for multiple stack configurations and move most secrets into the quay-config project.
This commit is contained in:
parent
8e9faf6121
commit
265fa5070a
23 changed files with 148 additions and 655 deletions
27
app.py
27
app.py
|
@ -1,7 +1,6 @@
|
|||
import logging
|
||||
import os
|
||||
import stripe
|
||||
import json
|
||||
|
||||
from flask import Flask
|
||||
from flask.ext.principal import Principal
|
||||
|
@ -11,30 +10,32 @@ from flask.ext.mail import Mail
|
|||
import features
|
||||
|
||||
from storage import Storage
|
||||
from config import DefaultConfig
|
||||
from data.userfiles import Userfiles
|
||||
from util.analytics import Analytics
|
||||
|
||||
|
||||
OVERRIDE_CONFIG_FILENAME = 'conf/stack/config.py'
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logger.debug('Loading default config.')
|
||||
app.config.from_object(DefaultConfig())
|
||||
|
||||
if 'QUAY_CONFIG_FILE' in os.environ:
|
||||
config_filename = os.environ['QUAY_CONFIG_FILE']
|
||||
logger.debug('Applying config file: %s', config_filename)
|
||||
app.config.from_pyfile(config_filename)
|
||||
if 'TEST' in os.environ:
|
||||
from test.testconfig import TestConfig
|
||||
logger.debug('Loading test config.')
|
||||
app.config.from_object(TestConfig())
|
||||
else:
|
||||
from config import DefaultConfig
|
||||
logger.debug('Loading default config.')
|
||||
app.config.from_object(DefaultConfig())
|
||||
|
||||
overrides = json.loads(os.environ.get('QUAY_CONFIG', '{}'))
|
||||
logger.debug('Applying %s config overrides.', len(overrides))
|
||||
app.config.from_object(overrides)
|
||||
if os.path.exists(OVERRIDE_CONFIG_FILENAME):
|
||||
logger.debug('Applying config file: %s', OVERRIDE_CONFIG_FILENAME)
|
||||
app.config.from_pyfile(OVERRIDE_CONFIG_FILENAME)
|
||||
|
||||
features.import_features(app.config)
|
||||
|
||||
print "Billing: %s" % features.BILLING
|
||||
|
||||
Principal(app, use_sessions=False)
|
||||
|
||||
login_manager = LoginManager()
|
||||
|
|
Reference in a new issue