diff options
Diffstat (limited to 'src/cli/hashi_env.py')
-rwxr-xr-x | src/cli/hashi_env.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/cli/hashi_env.py b/src/cli/hashi_env.py index aeac5ef..57708a8 100755 --- a/src/cli/hashi_env.py +++ b/src/cli/hashi_env.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -import datetime -import hashlib -import json import os +import json +import hashlib +import datetime import click import requests @@ -53,11 +53,7 @@ def get_ldap_password() -> str: """Return the LDAP password. The password is expected to be in 1password, under `LDAP'. """ - return ( - os.popen(f"/usr/local/bin/op read op://{op_vault}/LDAP/password") - .read() - .rstrip() - ) + return os.popen(f"/usr/local/bin/op read op://{op_vault}/LDAP/password").read().rstrip() def _get_token_from_cache(addr: str) -> str | None: @@ -109,9 +105,7 @@ def _vault_login(addr: str) -> str: except Exception as e: print("{} returned {}".format(url, str(e))) - expires_after = datetime.datetime.now() + datetime.timedelta( - seconds=resp.json()["auth"]["lease_duration"] - ) + expires_after = datetime.datetime.now() + datetime.timedelta(seconds=resp.json()["auth"]["lease_duration"]) token = resp.json()["auth"]["client_token"] _set_token_to_cache(addr, token, expires_after) |