Skip to content

Commit

Permalink
Add VAULT_TOKEN to command environment
Browse files Browse the repository at this point in the history
  • Loading branch information
crtschin authored and OpsBotPrime committed Jun 28, 2022
1 parent 128b11b commit 7027993
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ data Context
{ cLocalEnvVars :: [EnvVar]
, cCliOptions :: Options Validated Completed
, cHttpManager :: Manager
, cExtraEnvVars :: [EnvVar]
-- ^ Variables we want to inject into the command's environment that were not
-- in the local environment when vaultenv was called, nor fetched via vault
}

-- | The different types of Engine that Vautlenv supports
Expand Down Expand Up @@ -275,6 +278,7 @@ main = do
let context = Context { cLocalEnvVars = envAndEnvFileConfig
, cCliOptions = cliAndEnvAndEnvFileOptions
, cHttpManager = httpManager
, cExtraEnvVars = []
}

vaultEnv context >>= \case
Expand Down Expand Up @@ -329,7 +333,8 @@ vaultEnv originalContext =
Right mountInfo ->
requestSecrets authenticatedContext mountInfo secrets >>= \case
Left vaultError -> pure $ Left vaultError
Right secretEnv -> pure $ checkNoDuplicates (buildEnv secretEnv)
Right secretEnv -> pure $ checkNoDuplicates $
buildEnv (cExtraEnvVars authenticatedContext ++ secretEnv)
where
retryPolicy = vaultRetryPolicy (cCliOptions originalContext)

Expand All @@ -352,6 +357,7 @@ vaultEnv originalContext =
{ cCliOptions = (cCliOptions context)
{ oAuthMethod = AuthVaultToken token
}
, cExtraEnvVars = [("VAULT_TOKEN", unpack token)]
}

getMountInfo :: Context -> Retry.RetryStatus -> IO (Either VaultError MountInfo)
Expand Down

0 comments on commit 7027993

Please sign in to comment.