Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions gestalt/vault.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
from datetime import datetime, timedelta, timezone
from queue import Queue
Expand All @@ -14,6 +15,8 @@

EXPIRATION_THRESHOLD_HOURS = 1

logger = logging.getLogger(__name__)


class Vault(Provider):

Expand Down Expand Up @@ -93,7 +96,7 @@ def connect(self) -> None:
)

if token is not None:
print("Kubernetes login successful")
logger.info("Kubernetes login successful")
kubes_token = (
"kubernetes",
token["data"]["id"],
Expand Down Expand Up @@ -179,7 +182,7 @@ def get(self,
match = jsonpath_expression.find(secret)

if len(match) == 0:
print("Path returned not matches for your secret")
logger.warning("Path returned not matches for your secret")

returned_value_from_secret: Union[str, int, float,
List[Any]] = match[0].value
Expand Down Expand Up @@ -236,11 +239,11 @@ def _validate_token_expiration(self) -> None:
delta_time = (expire_time - current_time).total_seconds() / 3600

if delta_time < EXPIRATION_THRESHOLD_HOURS:
print(f"Re-authenticating with vault")
logger.info("Re-authenticating with vault")
self.connect()
else:
print(f"Token still valid for: {delta_time} hours")
logger.debug(f"Token still valid for: {delta_time} hours")
else:
print(
logger.warning(
f"Can't reconnect, token information: {self.kubes_token}, not valid"
)