Use VCAP_APPLICATION to detect CloudFoundry environment

VCAP_SERVICES is not set on PaaS if no services are bound to the
application, so we need to check for VCAP_APPLICATION to parse the
application name and environment.
This commit is contained in:
Alexey Bezhan
2018-01-09 14:41:36 +00:00
parent 945c967250
commit 0088d588e1
2 changed files with 4 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ def reload_config():
def test_load_cloudfoundry_config_if_available(monkeypatch, reload_config):
os.environ['API_HOST_NAME'] = 'env'
monkeypatch.setenv('VCAP_SERVICES', 'some json blob')
monkeypatch.setenv('VCAP_APPLICATION', 'some json blob')
with mock.patch('app.cloudfoundry_config.extract_cloudfoundry_config', side_effect=cf_conf) as cf_config:
# reload config so that its module level code (ie: all of it) is re-instantiated
@@ -41,7 +41,7 @@ def test_load_cloudfoundry_config_if_available(monkeypatch, reload_config):
def test_load_config_if_cloudfoundry_not_available(monkeypatch, reload_config):
os.environ['API_HOST_NAME'] = 'env'
monkeypatch.delenv('VCAP_SERVICES', raising=False)
monkeypatch.delenv('VCAP_APPLICATION', raising=False)
with mock.patch('app.cloudfoundry_config.extract_cloudfoundry_config') as cf_config:
# reload config so that its module level code (ie: all of it) is re-instantiated