Class VaultConfig
VaultClient (SPEC section 2.2).
Build one with builder() or read it from the environment with fromEnv().
Precedence: explicit builder value > SDK variable (EnvReader.DEFAULT_PREFIX + name)
> vendor variables > default. toString() never prints credentials.
Environment variables (fromEnv()): GROW_HASHICORP_VAULT_URL /
VAULT_ADDR, GROW_HASHICORP_VAULT_TOKEN / VAULT_TOKEN,
GROW_HASHICORP_VAULT_NAMESPACE / VAULT_NAMESPACE, GROW_HASHICORP_VAULT_CA_CERT /
VAULT_CACERT, GROW_HASHICORP_VAULT_CLIENT_CERT / VAULT_CLIENT_CERT,
GROW_HASHICORP_VAULT_CLIENT_KEY / VAULT_CLIENT_KEY,
GROW_HASHICORP_VAULT_INSECURE_SKIP_VERIFY / VAULT_SKIP_VERIFY,
GROW_HASHICORP_VAULT_KV_MOUNT, GROW_HASHICORP_VAULT_KV_VERSION (1, 2;
0 = auto-detect), GROW_HASHICORP_VAULT_SECRETS_PATH, plus
GROW_HASHICORP_VAULT_PROXY, the timeouts and GROW_HASHICORP_VAULT_MAX_RETRIES.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder of the configuration. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic VaultConfig.Builderbuilder()Starts an empty builder (every field at its default).Returns the connect timeout.static VaultConfigfromEnv()Reads the configuration from the process environment.static VaultConfigReads the configuration from an explicit variable map (tests).headers()Returns the extra request headers.hooks()Returns the hooks.kvMount()Returns the default KV mount (defaultsecret).Returns the fixed KV version that skips auto-detection.logger()Returns the logger.Returns the namespace sent asX-Vault-Namespace.proxy()Returns the explicit proxy URL.Returns the per-attempt timeout.retry()Returns the retry policy.Returns the base path ofclient.secrets()inside the KV mount.tls()Returns the TLS options.token()Returns the API token.toString()Returns the total timeout per call including retries.Translates the common fields into transport settings.toTransportConfig(Supplier<Collection<String>> knownSecrets) Translates the common fields into transport settings with a custom source of secret values to redact (the client adds tokens obtained by a login).url()Returns the endpoint base URL.Returns the user agent suffix.voidvalidate()Checks URL scheme, positive timeouts, retry limits and TLS pairs.Returns the KV data field that holds aclient.secrets()value.
-
Field Details
-
DEFAULT_URL
Default endpoint.- See Also:
-
DEFAULT_KV_MOUNT
Default KV mount used byclient.kv()andclient.secrets().- See Also:
-
DEFAULT_VALUE_FIELD
Default KV data field that holds aclient.secrets()value.- See Also:
-
-
Method Details
-
builder
Starts an empty builder (every field at its default).- Returns:
- a new builder
-
fromEnv
Reads the configuration from the process environment.- Returns:
- the validated configuration
- Throws:
ConfigException- when a variable holds an invalid value (the message names the variable, never the value)
-
fromEnv
Reads the configuration from an explicit variable map (tests).- Parameters:
env- variable map- Returns:
- the validated configuration
-
validate
public void validate()Checks URL scheme, positive timeouts, retry limits and TLS pairs.- Throws:
ConfigException- when a rule is violated
-
toTransportConfig
Translates the common fields into transport settings.- Returns:
- the transport configuration
-
toTransportConfig
Translates the common fields into transport settings with a custom source of secret values to redact (the client adds tokens obtained by a login).- Parameters:
knownSecrets- supplier of credential values removed from error messages- Returns:
- the transport configuration
-
url
Returns the endpoint base URL.- Returns:
- the URL
-
token
Returns the API token.- Returns:
- the token, or empty
-
connectTimeout
Returns the connect timeout.- Returns:
- the timeout
-
requestTimeout
Returns the per-attempt timeout.- Returns:
- the timeout
-
totalTimeout
Returns the total timeout per call including retries.- Returns:
- the timeout
-
retry
Returns the retry policy.- Returns:
- the policy
-
tls
Returns the TLS options.- Returns:
- the options
-
proxy
Returns the explicit proxy URL.- Returns:
- the proxy, or empty
-
headers
Returns the extra request headers.- Returns:
- immutable map
-
userAgentSuffix
Returns the user agent suffix.- Returns:
- the suffix, or empty
-
hooks
Returns the hooks.- Returns:
- the hooks
-
logger
Returns the logger.- Returns:
- the logger
-
namespace
Returns the namespace sent asX-Vault-Namespace.- Returns:
- the namespace, or empty
-
kvMount
Returns the default KV mount (defaultsecret).- Returns:
- the mount
-
kvVersion
Returns the fixed KV version that skips auto-detection.- Returns:
- 1 or 2, or empty for auto-detection per mount
-
secretsPath
Returns the base path ofclient.secrets()inside the KV mount.- Returns:
- the path without surrounding slashes (
""= the mount root)
-
valueField
Returns the KV data field that holds aclient.secrets()value.- Returns:
- the field (default
value)
-
toString
-