mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-23 09:29:43 -04:00
Replace direct access of os.environ with getenv()
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import json
|
||||
import os
|
||||
from os import getenv
|
||||
|
||||
|
||||
class CloudfoundryConfig:
|
||||
def __init__(self):
|
||||
self.parsed_services = json.loads(os.environ.get('VCAP_SERVICES') or '{}')
|
||||
self.parsed_services = json.loads(getenv('VCAP_SERVICES') or '{}')
|
||||
buckets = self.parsed_services.get('s3') or []
|
||||
self.s3_buckets = {bucket['name']: bucket['credentials'] for bucket in buckets}
|
||||
self._empty_bucket_credentials = {
|
||||
@@ -16,7 +16,7 @@ class CloudfoundryConfig:
|
||||
|
||||
@property
|
||||
def database_url(self):
|
||||
return os.environ.get('DATABASE_URL', '').replace('postgres://', 'postgresql://')
|
||||
return getenv('DATABASE_URL', '').replace('postgres://', 'postgresql://')
|
||||
|
||||
@property
|
||||
def redis_url(self):
|
||||
@@ -26,7 +26,7 @@ class CloudfoundryConfig:
|
||||
'rediss://'
|
||||
)
|
||||
except KeyError:
|
||||
return os.environ.get('REDIS_URL')
|
||||
return getenv('REDIS_URL')
|
||||
|
||||
def s3_credentials(self, service_name):
|
||||
return self.s3_buckets.get(service_name) or self._empty_bucket_credentials
|
||||
|
||||
Reference in New Issue
Block a user