import os


class Config():
    __instance = None

    @staticmethod
    def instance():
        if Config.__instance is None:
            Config()
        return Config.__instance

    @staticmethod
    def clear():
        Config.__instance = None

    def __init__(self):
        if Config.__instance is not None:
            raise Exception("Config is a singleton class.")
        self._trust_ssl = os.environ.get('CTERA_FILER_TRUST_SSL', "Consent")
        self._hostname = os.environ.get('CTERA_FILER_ADDRESS', '127.0.0.1')
        self._jwt_secret = os.environ.get('CTERA_FILER_JWT_SECRET')
        if self._jwt_secret is None:
            raise Exception("Environment variable CTERA_FILER_JWT_SECRET is not set")
        Config.__instance = self

    @property
    def trust_ssl(self):
        return self._trust_ssl

    @property
    def hostname(self):
        return self._hostname

    @property
    def jwt_secret(self):
        return self._jwt_secret
