From 1fc7cf757197e5fc594dd58e7a5425f29abc0fb7 Mon Sep 17 00:00:00 2001 From: Ruud van Asseldonk Date: Fri, 7 Oct 2022 11:13:09 +0200 Subject: [PATCH] Add a bit more logging at info level --- app/Main.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 2ea79b4..fd0a08e 100755 --- a/app/Main.hs +++ b/app/Main.hs @@ -6,7 +6,7 @@ import Control.Applicative ((<|>)) import Control.Concurrent.QSem (newQSem, waitQSem, signalQSem) import Control.Exception (Handler (..), bracket_, catch, catches) -import Control.Monad (forM) +import Control.Monad (forM, when) import Control.Monad.IO.Class (MonadIO, liftIO) import Data.Aeson (FromJSON, (.:)) import Data.Aeson.Types (parseMaybe) @@ -352,8 +352,10 @@ vaultEnv originalContext = handleVaultAuthResponse context f = catch f httpErrorHandler >>= \case Left vaultError -> pure $ Left vaultError - Right (ClientToken token) -> pure $ - Right context + Right (ClientToken token) -> do + when (getOptionsValue oLogLevel (cCliOptions context) <= Info) $ + putStrLn "[INFO] Authentication successful, we have a VAULT_TOKEN now." + pure $ Right context { cCliOptions = (cCliOptions context) { oAuthMethod = AuthVaultToken token } @@ -464,6 +466,8 @@ requestGitHubVaultToken context ghtoken = let -- | Authenticate using Kubernetes auth, see https://www.vaultproject.io/docs/auth/kubernetes. requestKubernetesVaultToken :: Context -> Text -> IO (Either VaultError ClientToken) requestKubernetesVaultToken context role = do + when (getOptionsValue oLogLevel (cCliOptions context) <= Info) $ + putStrLn "[INFO] Authenticating with Kubernetes ..." jwtResult <- readKubernetesJwt case jwtResult of Left err -> pure $ Left err @@ -517,7 +521,9 @@ requestSecret context secretPath = getSecret :: Retry.RetryStatus -> IO (Either VaultError VaultData) getSecret _retryStatus = catch (doRequest secretPath request) httpErrorHandler - in + in do + when (getOptionsValue oLogLevel (cCliOptions context) <= Info) $ + putStrLn $ "[INFO] Getting " <> secretPath <> " ..." doWithRetries retryPolicy getSecret -- | Request all the supplied secrets from the vault, but just once, even if