Skip to content

Commit

Permalink
Add support for the VAULT_NAMESPACE environment variable
Browse files Browse the repository at this point in the history
If the Client class is instantiated without the namespace argument, use
the content of the VAULT_NAMESPACE environment variable instead,
mimicking the behaviour of the official vault CLI tool.
  • Loading branch information
mporrato committed Oct 2, 2021
1 parent ec048de commit 69ce31a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
10 changes: 0 additions & 10 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ Using TLS with client-side certificate authentication:
True


Using `Vault Enterprise namespace <https://www.vaultproject.io/docs/enterprise/namespaces/index.html>`_\ :

.. doctest:: init

>>> client = hvac.Client(
... url='https://localhost:8200',
... namespace=os.getenv('VAULT_NAMESPACE'),
... )


Using plaintext / HTTP (not recommended for anything other than development work):

.. doctest:: init
Expand Down
1 change: 1 addition & 0 deletions hvac/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(

token = token if token is not None else utils.get_token_from_env()
url = url if url else os.getenv("VAULT_ADDR", DEFAULT_URL)
namespace = namespace if namespace else os.getenv("VAULT_NAMESPACE")

if cert is not None and VAULT_CLIENT_CERT:
cert = "\n".join(
Expand Down

0 comments on commit 69ce31a

Please sign in to comment.