Make get_secret return None instead of an exception if the secret isn't defined.

Remove empty key generation from generate_enterprise_secrets, since get_secret ignores missing keys now.

(imported from commit 32d61e3058f0d41bfb4b17775e581a3c84540fe7)
This commit is contained in:
Yoyo Zhou 2015-08-20 21:51:35 -07:00
parent 2cab113035
commit ec5ed87ca0
2 changed files with 4 additions and 7 deletions

View File

@ -16,9 +16,6 @@ CAMO_CONFIG_FILENAME = '/etc/default/camo'
AUTOGENERATED_SETTINGS = ['shared_secret', 'avatar_salt', 'rabbitmq_password', 'local_database_password',
'initial_password_salt']
EMPTY_SETTINGS = ['deployment_role_key', 'mandrill_api_key', 'mailchimp_api_key', 'email_password', 's3_key', 's3_secret_key',
'google_oauth2_client_secret', 'dev_google_oauth2_client_secret']
def generate_camo_config_file(camo_key):
camo_config = """ENABLED=yes
PORT=9292
@ -54,9 +51,6 @@ def generate_secrets(development=False):
# Write the Camo config file directly
generate_camo_config_file(camo_key)
for name in EMPTY_SETTINGS:
lines.append(config_line(name, ''))
out = open(OUTPUT_SETTINGS_FILENAME, 'w')
out.write("".join(lines))
out.close()

View File

@ -21,7 +21,10 @@ if DEPLOYED:
else:
secrets_file.read("zproject/dev-secrets.conf")
get_secret = lambda x: secrets_file.get('secrets', x)
def get_secret(key):
if secrets_file.has_option('secrets', key):
return secrets_file.get('secrets', key)
return None
MAILCHIMP_API_KEY = get_secret("mailchimp_api_key")
ZULIP_FRIENDS_LIST_ID = '84b2f3da6b'