Skip to content

Commit

Permalink
Merge branch 'master' into add-sandbox-config
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmundy authored Sep 5, 2020
2 parents aa68c1a + 986d22c commit 6992eda
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ webargs = "*"
flask-sqlalchemy = "*"
sqlalchemy = "*"
psycopg2-binary = "*"
mci-database = {editable = true,git = "http://github.com/brighthive/mci-database.git"}
mci-database = {editable = true,git = "https://github.com/brighthive/mci-database.git",ref = "master"}

[requires]
python_version = "3.7"
126 changes: 63 additions & 63 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions matching/config/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os


class Config(object):
DEBUG = False
TESTING = False


class DevelopmentConfig(Config):
def __init__(self):
super().__init__()
Expand All @@ -15,10 +17,10 @@ def __init__(self):
POSTGRES_PASSWORD = 'test_password'
POSTGRES_DATABASE = 'mci_dev'
POSTGRES_PORT = '5432'
# POSTGRES_HOSTNAME = 'localhost'
# POSTGRES_HOSTNAME = 'localhost'
POSTGRES_HOSTNAME = 'docker_postgres_mci_1'
# If the matching-service is running in a Docker container, then connect to the
# mci psql container, rather than localhost.
# If the matching-service is running in a Docker container, then connect to the
# mci psql container, rather than localhost.
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
POSTGRES_USER,
POSTGRES_PASSWORD,
Expand Down Expand Up @@ -68,6 +70,27 @@ def __init__(self):
POSTGRES_DATABASE
)


class ProductionConfig(Config):
def __init__(self):
super().__init__()
os.environ['FLASK_ENV'] = 'production'

DEBUG = False
POSTGRES_USER = os.getenv('POSTGRES_USER', 'brighthive')
POSTGRES_PASSWORD = os.getenv('POSTGRES_PASSWORD', 'test_password')
POSTGRES_DATABASE = os.getenv('POSTGRES_DATABASE', 'mci_test')
POSTGRES_HOSTNAME = os.getenv('POSTGRES_HOSTNAME', 'localhost')
POSTGRES_PORT = os.getenv('POSTGRES_PORT', '5432')
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format(
POSTGRES_USER,
POSTGRES_PASSWORD,
POSTGRES_HOSTNAME,
POSTGRES_PORT,
POSTGRES_DATABASE
)


class ConfigurationFactory(object):
"""Application configuration factory.
This factoty class provides a quick and easy mechanism for retrieving a specific configuration
Expand All @@ -94,6 +117,8 @@ def get_config(config_type: str):
return DevelopmentConfig()
elif config_type.upper() == 'SANDBOX':
return SandboxConfig()
elif config_type.upper() == 'PRODUCTION':
return ProductionConfig()

@staticmethod
def from_env():
Expand Down

0 comments on commit 6992eda

Please sign in to comment.