Package codes.grow.packages.vault
Class VaultConfig.Builder
java.lang.Object
codes.grow.packages.vault.VaultConfig.Builder
- Enclosing class:
VaultConfig
Builder of the configuration.
Unset fields take the environment (when fromEnv(EnvReader) is called) or the
default.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and validates the configuration.Sets the connect timeout (default 10 s).Fills every field that was not set explicitly from the environment.Adds a header sent with every request.Sets request hooks.Sets the default KV mount (defaultsecret).kvVersion(int kvVersion) Fixes the KV version of every mount and skips auto-detection (sys/internal/ui/mounts); set it for tokens that cannot read the preflight endpoint.Sets the logger (default silent).Sets the namespace sent asX-Vault-Namespace(envGROW_HASHICORP_VAULT_NAMESPACE,VAULT_NAMESPACE).Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.Sets the per-attempt timeout (default 30 s).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).secretsPath(String secretsPath) Sets the base path inside the KV mount under whichclient.secrets()stores secrets (envGROW_HASHICORP_VAULT_SECRETS_PATH, default""= the mount root).tls(TlsOptions tls) Sets the TLS options; environment TLS variables are then ignored.Sets the API token.Sets the API token.Sets the total timeout per call including retries (default 120 s).Sets the endpoint base URL.userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.valueField(String valueField) Sets the KV data field that holds aclient.secrets()value (defaultvalue).
-
Method Details
-
fromEnv
Fills every field that was not set explicitly from the environment.- Parameters:
env- environment reader- Returns:
- this builder
- Throws:
ConfigException- when a variable holds an invalid value
-
secretsPath
Sets the base path inside the KV mount under whichclient.secrets()stores secrets (envGROW_HASHICORP_VAULT_SECRETS_PATH, default""= the mount root).- Parameters:
secretsPath- base path- Returns:
- this builder
-
valueField
Sets the KV data field that holds aclient.secrets()value (defaultvalue).- Parameters:
valueField- field name- Returns:
- this builder
-
namespace
Sets the namespace sent asX-Vault-Namespace(envGROW_HASHICORP_VAULT_NAMESPACE,VAULT_NAMESPACE).- Parameters:
namespace- namespace path, e.g.team-a- Returns:
- this builder
-
kvMount
Sets the default KV mount (defaultsecret).- Parameters:
kvMount- mount path- Returns:
- this builder
-
kvVersion
Fixes the KV version of every mount and skips auto-detection (sys/internal/ui/mounts); set it for tokens that cannot read the preflight endpoint.- Parameters:
kvVersion- 1 or 2- Returns:
- this builder
-
url
Sets the endpoint base URL.- Parameters:
url-httporhttpsURL- Returns:
- this builder
-
token
Sets the API token.- Parameters:
token- token- Returns:
- this builder
-
token
Sets the API token.- Parameters:
token- token- Returns:
- this builder
-
connectTimeout
Sets the connect timeout (default 10 s).- Parameters:
d- positive duration- Returns:
- this builder
-
requestTimeout
Sets the per-attempt timeout (default 30 s).- Parameters:
d- positive duration- Returns:
- this builder
-
totalTimeout
Sets the total timeout per call including retries (default 120 s).- Parameters:
d- positive duration- Returns:
- this builder
-
retry
Sets the retry policy (defaultRetryPolicy.defaults()).- Parameters:
retry- policy- Returns:
- this builder
-
tls
Sets the TLS options; environment TLS variables are then ignored.- Parameters:
tls- options- Returns:
- this builder
-
proxy
Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.- Parameters:
proxy- proxy URL- Returns:
- this builder
-
header
Adds a header sent with every request.- Parameters:
name- header namevalue- header value- Returns:
- this builder
-
userAgentSuffix
Sets the text appended to theUser-Agent.- Parameters:
suffix- suffix- Returns:
- this builder
-
hooks
Sets request hooks.- Parameters:
hooks- hooks- Returns:
- this builder
-
logger
Sets the logger (default silent).- Parameters:
logger- logger- Returns:
- this builder
-
build
Builds and validates the configuration.- Returns:
- the configuration
- Throws:
ConfigException- when a rule is violated
-