Skip to content

vault

vault

read_vault_secret

read_vault_secret(secret_name)

Return the value of secret_name fetched from Vault.

Raises KeyError if the secret has no vault mapping or the field is absent. Raises ValueError if the field exists but is empty. Raises requests.HTTPError / ConnectionError on network / auth failures.

Source code in source/src/vault.py
def read_vault_secret(secret_name):
    """Return the value of *secret_name* fetched from Vault.

    Raises KeyError  if the secret has no vault mapping or the field is absent.
    Raises ValueError if the field exists but is empty.
    Raises requests.HTTPError / ConnectionError on network / auth failures.
    """
    print("requested secret from vault: " + secret_name)
    global _client
    if _client is None:
        _client = _VaultClient()
    return _client.read_secret(secret_name)