Skip to content

Commit

Permalink
Permit configuration via environment variables; remove default config…
Browse files Browse the repository at this point in the history
… file in favor of CONFIG_FILE= environment variable
  • Loading branch information
stewartadam committed Jun 2, 2018
1 parent 3c378a4 commit c2e608f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
1 change: 1 addition & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
flask
flask-env
flask-failsafe
flask-sqlalchemy
flask-limiter
Expand Down
5 changes: 3 additions & 2 deletions server/zkvgateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from flask_limiter.util import get_remote_address

app = flask.Flask(__name__)
app.config.from_object('zkvgateway.config.DefaultConfig')
app.config.from_envvar('CONFIG_FILE', silent=True)

limiter = Limiter(
app,
key_func=get_remote_address
)
app.config.from_object('zkvgateway.config.DefaultConfig')
app.config.from_pyfile('zfs-keyvault-gateway.cfg')

db = flask_sqlalchemy.SQLAlchemy(app)

Expand Down
8 changes: 6 additions & 2 deletions server/zkvgateway/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
class DefaultConfig(object):
from flask_env import MetaFlaskEnv

class DefaultConfig(metaclass=MetaFlaskEnv):
ENV_PREFIX = 'ZKV_'

DEBUG = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///db.sqlite'
SQLALCHEMY_TRACK_MODIFICATIONS = False

AAD_RESOURCE = 'https://vault.azure.net'
AAD_AUTHORITY_HOST_URI = 'https://login.microsoftonline.com'
MAX_WAIT = 30
MAX_WAIT = 60
PIN_LENGTH = 6

AAD_CLIENT_ID = 'guid-here'
Expand Down
15 changes: 0 additions & 15 deletions server/zkvgateway/zfs-keyvault-gateway.cfg.sample

This file was deleted.

0 comments on commit c2e608f

Please sign in to comment.