fga-eps-mds/2019.1-unbrake

View on GitHub
unbrake-api/utils/general.py

Summary

Maintainability
A
0 mins
Test Coverage
'''
For keeping general util functions to the whole project
'''

import os


def get_secret(secret_name):
    '''
    For getting project secrets which are mount on docker-compose files
    '''

    key_file = None
    try:
        key_file = open(os.path.join('/', 'run', 'secrets', secret_name))
    except FileNotFoundError:
        raise FileNotFoundError(
            f"""
            ===================================================================
            '{secret_name}' secret not found.
            Ask the development team the secrets or use your owns.
            ===================================================================
            """
        )

    return key_file.read().strip()