Esempio n. 1
0
def generate_uppercase_key(key, namespace=None):
    """Given a key and a namespace, generates a final uppercase key."""
    if namespace:
        namespace = [part for part in listify(namespace) if part]
        key = "_".join(namespace + [key])

    key = key.upper()
    return key
    def get(self, key, namespace=None):
        # The namespace is either None, a string or a list of
        # strings. This converts it into a list.
        namespace = listify(namespace)

        # FIXME: Your code to extract the key in namespace here.

        # At this point, the key doesn't exist in the namespace
        # for this environment, so return a ``NO_VALUE``.
        return NO_VALUE
Esempio n. 3
0
    def __init__(self, possible_paths):
        self.cfg = {}
        self.path = None
        possible_paths = listify(possible_paths)

        for path in possible_paths:
            if not path:
                continue

            path = os.path.abspath(os.path.expanduser(path.strip()))
            if path and os.path.isfile(path):
                self.path = path
                self.cfg.update(self.parse_ini_file(path))
                break

        if not self.path:
            logger.debug('No INI file found: %s', possible_paths)
Esempio n. 4
0
    def __init__(self, possible_paths):
        self.cfg = {}
        self.path = None
        possible_paths = listify(possible_paths)

        for path in possible_paths:
            if not path:
                continue

            path = os.path.abspath(os.path.expanduser(path.strip()))
            if path and os.path.isfile(path):
                self.path = path
                self.cfg = self.parse_yaml_file(path)
                break

        if not self.path:
            logger.debug("No YAML file found: %s", possible_paths)
Esempio n. 5
0
    def __init__(self, possible_paths):
        self.cfg = {}
        self.path = None
        possible_paths = listify(possible_paths)

        for path in possible_paths:
            if not path:
                continue

            path = os.path.abspath(os.path.expanduser(path.strip()))
            if path and os.path.isfile(path):
                self.path = path
                self.cfg = self.parse_yaml_file(path)
                break

        if not self.path:
            logger.debug('No YAML file found: %s', possible_paths)
Esempio n. 6
0
    def get(self, key, namespace=None):
        # The namespace is either None, a string or a list of
        # strings. This converts it into a list.
        namespace = listify(namespace)
        try:
            if len(namespace) > 0:
                secret = getSecret(
                    name="{}.{}".format(namespace[0], key),
                    context={"app": "sso-dashboard"},
                    region="us-east-1",
                )
            else:
                secret = None
        except ItemNotFound:
            secret = None

        if secret is not None:
            return secret

        return NO_VALUE
Esempio n. 7
0
def test_listify(data, expected):
    assert listify(data) == expected
Esempio n. 8
0
def test_listify(data, expected):
    assert listify(data) == expected