mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Integrated credstash as a live properties setting in the app.py class
- initial versions kept it out of this class but updated as lots of duplication and errors as config set up in multiple places and not all picking up credstash.
This commit is contained in:
@@ -13,7 +13,7 @@ from app.its_dangerous_session import ItsdangerousSessionInterface
|
||||
import app.proxy_fix
|
||||
from config import configs
|
||||
from utils import logging
|
||||
|
||||
from credstash import getAllSecrets
|
||||
|
||||
db = SQLAlchemy()
|
||||
login_manager = LoginManager()
|
||||
@@ -76,6 +76,13 @@ def init_app(app):
|
||||
if key in os.environ:
|
||||
app.config[key] = convert_to_boolean(os.environ[key])
|
||||
|
||||
if app.config['NOTIFY_ADMIN_ENVIRONMENT'] == 'live':
|
||||
secrets = getAllSecrets(region="eu-west-1")
|
||||
|
||||
for key in app.config.keys():
|
||||
if key in secrets:
|
||||
app.config[key] = secrets[key]
|
||||
|
||||
@app.context_processor
|
||||
def inject_global_template_variables():
|
||||
return {'asset_path': '/static/'}
|
||||
|
||||
4
db.py
4
db.py
@@ -1,5 +1,3 @@
|
||||
from app import create_app
|
||||
import os
|
||||
from credstash import getAllSecrets
|
||||
from flask.ext.script import Manager, Server
|
||||
from flask_migrate import Migrate, MigrateCommand
|
||||
@@ -7,7 +5,7 @@ from app import create_app, db
|
||||
|
||||
secrets = getAllSecrets(region="eu-west-1")
|
||||
|
||||
application = create_app(os.getenv('NOTIFICATIONS_ADMIN_ENVIRONMENT') or 'live')
|
||||
application = create_app('live')
|
||||
|
||||
for key in application.config.keys():
|
||||
if key in secrets:
|
||||
|
||||
18
wsgi.py
18
wsgi.py
@@ -1,22 +1,6 @@
|
||||
from app import create_app
|
||||
import os
|
||||
from credstash import getAllSecrets
|
||||
from flask.ext.script import Manager, Server
|
||||
from flask_migrate import Migrate, MigrateCommand
|
||||
from app import create_app, db
|
||||
|
||||
secrets = getAllSecrets(region="eu-west-1")
|
||||
|
||||
application = create_app(os.getenv('NOTIFICATIONS_ADMIN_ENVIRONMENT') or 'live')
|
||||
|
||||
for key in application.config.keys():
|
||||
if key in secrets:
|
||||
application.config[key] = secrets[key]
|
||||
|
||||
|
||||
manager = Manager(application)
|
||||
migrate = Migrate(application, db)
|
||||
manager.add_command('db', MigrateCommand)
|
||||
application = create_app('live')
|
||||
|
||||
if __name__ == "__main__":
|
||||
application.run()
|
||||
|
||||
Reference in New Issue
Block a user