Merge pull request #850 from alphagov/paas_redis_config

Get Redis config from PaaS
This commit is contained in:
Andras Ferencz-Szabo
2017-03-03 12:41:50 +00:00
committed by GitHub
5 changed files with 36 additions and 2 deletions
+7
View File
@@ -32,6 +32,8 @@ def set_config_env_vars(vcap_services):
extract_mmg_config(s) extract_mmg_config(s)
elif s['name'] == 'firetext': elif s['name'] == 'firetext':
extract_firetext_config(s) extract_firetext_config(s)
elif s['name'] == 'redis':
extract_redis_config(s)
def extract_notify_config(notify_config): def extract_notify_config(notify_config):
@@ -60,3 +62,8 @@ def extract_mmg_config(mmg_config):
def extract_firetext_config(firetext_config): def extract_firetext_config(firetext_config):
os.environ['FIRETEXT_API_KEY'] = firetext_config['credentials']['api_key'] os.environ['FIRETEXT_API_KEY'] = firetext_config['credentials']['api_key']
os.environ['LOADTESTING_API_KEY'] = firetext_config['credentials']['loadtesting_api_key'] os.environ['LOADTESTING_API_KEY'] = firetext_config['credentials']['loadtesting_api_key']
def extract_redis_config(redis_config):
os.environ['REDIS_ENABLED'] = redis_config['credentials']['redis_enabled']
os.environ['REDIS_URL'] = redis_config['credentials']['redis_url']
+4
View File
@@ -54,6 +54,10 @@ def process_ses_response():
client_name = 'SES' client_name = 'SES'
try: try:
ses_request = json.loads(request.data) ses_request = json.loads(request.data)
if 'Type' in ses_request and ses_request['Type'] == 'SubscriptionConfirmation':
current_app.logger.info("SNS subscription confirmation url: {}".format(ses_request['SubscribeURL']))
errors = validate_callback_data(data=ses_request, fields=['Message'], client_name=client_name) errors = validate_callback_data(data=ses_request, fields=['Message'], client_name=client_name)
if errors: if errors:
raise InvalidRequest(errors, status_code=400) raise InvalidRequest(errors, status_code=400)
+1
View File
@@ -9,6 +9,7 @@ services:
- mmg - mmg
- firetext - firetext
- hosted-graphite - hosted-graphite
- redis
env: env:
NOTIFY_APP_NAME: public-api NOTIFY_APP_NAME: public-api
CW_APP_NAME: api CW_APP_NAME: api
+1
View File
@@ -10,6 +10,7 @@ services:
- mmg - mmg
- firetext - firetext
- hosted-graphite - hosted-graphite
- redis
instances: 1 instances: 1
memory: 512M memory: 512M
+23 -2
View File
@@ -75,6 +75,17 @@ def postgres_config():
] ]
@pytest.fixture
def redis_config():
return {
'name': 'redis',
'credentials': {
'redis_enabled': '1',
'redis_url': 'redis url'
}
}
@pytest.fixture @pytest.fixture
def cloudfoundry_config( def cloudfoundry_config(
postgres_config, postgres_config,
@@ -82,7 +93,8 @@ def cloudfoundry_config(
aws_config, aws_config,
hosted_graphite_config, hosted_graphite_config,
mmg_config, mmg_config,
firetext_config firetext_config,
redis_config
): ):
return { return {
'postgres': postgres_config, 'postgres': postgres_config,
@@ -91,7 +103,8 @@ def cloudfoundry_config(
aws_config, aws_config,
hosted_graphite_config, hosted_graphite_config,
mmg_config, mmg_config,
firetext_config firetext_config,
redis_config
] ]
} }
@@ -165,3 +178,11 @@ def test_firetext_config():
assert os.environ['FIRETEXT_API_KEY'] == 'firetext api key' assert os.environ['FIRETEXT_API_KEY'] == 'firetext api key'
assert os.environ['LOADTESTING_API_KEY'] == 'loadtesting api key' assert os.environ['LOADTESTING_API_KEY'] == 'loadtesting api key'
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
def test_redis_config():
extract_cloudfoundry_config()
assert os.environ['REDIS_ENABLED'] == '1'
assert os.environ['REDIS_URL'] == 'redis url'