Vaultx.Base.Config (Vaultx v0.7.0)
View SourceSimplified configuration interface for VaultX.
This module provides a clean, backward-compatible interface to the modern configuration system. All functionality is delegated to the specialized configuration modules for better maintainability.
Design Philosophy
- Delegation: All functionality delegates to modern config system
- Backward Compatibility: Maintains existing API for legacy code
- Simplicity: No duplicate logic, single source of truth
- Performance: Direct delegation without overhead
Configuration Sources
Configuration is resolved in the following priority order:
- Environment variables (highest priority)
- Application configuration
- Default values (lowest priority)
Usage Examples
# Get complete configuration
config = Vaultx.Base.Config.get()
# Get specific values
url = Vaultx.Base.Config.get_url()
token = Vaultx.Base.Config.get_token()
# Get multiple values efficiently
%{url: url, timeout: timeout} = Vaultx.Base.Config.get_values([:url, :timeout])
Summary
Functions
Checks if authentication is configured.
Gets a list of enabled features.
Checks if a specific feature is enabled.
Gets the status of all features.
Gets the complete configuration with all resolved values.
Gets whether audit logging is enabled.
Gets the CA certificate file path.
Gets the CA certificates directory.
Gets whether caching is enabled.
Gets the client certificate file path.
Gets the client private key file path.
Gets the connection timeout in milliseconds.
Gets the logger level.
Gets the maximum retry delay in milliseconds.
Gets whether metrics collection is enabled.
Gets configuration using the modern system with comprehensive validation.
Gets the Vault namespace.
Gets pool configuration as a map.
Gets the pool maximum idle time in milliseconds.
Gets the connection pool size.
Gets the rate limit burst size.
Gets whether rate limiting is enabled.
Gets the rate limit requests per second.
Gets the number of retry attempts.
Gets the retry backoff strategy.
Gets retry configuration as a map.
Gets the retry delay in milliseconds.
Gets whether security headers are enabled.
Gets whether SSL verification is enabled.
Gets whether telemetry is enabled.
Gets the request timeout in milliseconds.
Gets the minimum TLS version.
Gets the TLS server name for verification.
Gets the authentication token.
Gets whether token renewal is enabled.
Gets the token renewal threshold percentage.
Gets the Vault server URL.
Gets a specific configuration value by key.
Gets multiple configuration values efficiently.
Checks if SSL/TLS is properly configured.
Types
@type retry_backoff() :: :linear | :exponential
@type t() :: %{ url: String.t(), token: String.t() | nil, namespace: String.t() | nil, timeout: pos_integer(), connect_timeout: pos_integer(), retry_attempts: non_neg_integer(), retry_delay: pos_integer(), retry_backoff: retry_backoff(), max_retry_delay: pos_integer(), ssl_verify: boolean(), cacert: String.t() | nil, cacerts_dir: String.t() | nil, client_cert: String.t() | nil, client_key: String.t() | nil, tls_server_name: String.t() | nil, tls_min_version: String.t(), pool_size: pos_integer(), pool_max_idle_time: pos_integer(), logger_level: atom(), telemetry_enabled: boolean(), audit_enabled: boolean(), metrics_enabled: boolean(), cache_enabled: boolean(), rate_limit_enabled: boolean(), rate_limit_requests: pos_integer(), rate_limit_burst: non_neg_integer(), token_renewal_enabled: boolean(), token_renewal_threshold: pos_integer(), security_headers_enabled: boolean() }
Functions
@spec auth_configured?() :: boolean()
Checks if authentication is configured.
@spec enabled_features() :: [atom()]
Gets a list of enabled features.
Checks if a specific feature is enabled.
@spec features_status() :: %{ enabled: [atom()], disabled: [atom()], recommendations: [String.t()] }
Gets the status of all features.
@spec get() :: t()
Gets the complete configuration with all resolved values.
This function delegates to the modern configuration system.
Examples
iex> config = Vaultx.Base.Config.get()
iex> config.url
"https://vault.example.com:8200"
@spec get_audit_enabled() :: boolean()
Gets whether audit logging is enabled.
@spec get_cacert() :: String.t() | nil
Gets the CA certificate file path.
@spec get_cacerts_dir() :: String.t() | nil
Gets the CA certificates directory.
@spec get_cache_enabled() :: boolean()
Gets whether caching is enabled.
@spec get_client_cert() :: String.t() | nil
Gets the client certificate file path.
@spec get_client_key() :: String.t() | nil
Gets the client private key file path.
@spec get_connect_timeout() :: pos_integer()
Gets the connection timeout in milliseconds.
@spec get_logger_level() :: atom()
Gets the logger level.
@spec get_max_retry_delay() :: pos_integer()
Gets the maximum retry delay in milliseconds.
@spec get_metrics_enabled() :: boolean()
Gets whether metrics collection is enabled.
@spec get_modern() :: {:ok, t()} | {:error, Vaultx.Base.Error.t()}
Gets configuration using the modern system with comprehensive validation.
This is the preferred method for new code.
@spec get_namespace() :: String.t() | nil
Gets the Vault namespace.
@spec get_pool_config() :: %{size: pos_integer(), max_idle_time: pos_integer()}
Gets pool configuration as a map.
@spec get_pool_max_idle_time() :: pos_integer()
Gets the pool maximum idle time in milliseconds.
@spec get_pool_size() :: pos_integer()
Gets the connection pool size.
@spec get_rate_limit_burst() :: non_neg_integer()
Gets the rate limit burst size.
@spec get_rate_limit_enabled() :: boolean()
Gets whether rate limiting is enabled.
@spec get_rate_limit_requests() :: pos_integer()
Gets the rate limit requests per second.
@spec get_retry_attempts() :: non_neg_integer()
Gets the number of retry attempts.
@spec get_retry_backoff() :: retry_backoff()
Gets the retry backoff strategy.
@spec get_retry_config() :: %{ attempts: non_neg_integer(), delay: pos_integer(), backoff: retry_backoff(), max_delay: pos_integer() }
Gets retry configuration as a map.
@spec get_retry_delay() :: pos_integer()
Gets the retry delay in milliseconds.
@spec get_security_headers_enabled() :: boolean()
Gets whether security headers are enabled.
@spec get_ssl_verify() :: boolean()
Gets whether SSL verification is enabled.
@spec get_telemetry_enabled() :: boolean()
Gets whether telemetry is enabled.
@spec get_timeout() :: pos_integer()
Gets the request timeout in milliseconds.
@spec get_tls_min_version() :: String.t()
Gets the minimum TLS version.
@spec get_tls_server_name() :: String.t() | nil
Gets the TLS server name for verification.
@spec get_token() :: String.t() | nil
Gets the authentication token.
@spec get_token_renewal_enabled() :: boolean()
Gets whether token renewal is enabled.
@spec get_token_renewal_threshold() :: pos_integer()
Gets the token renewal threshold percentage.
@spec get_url() :: String.t()
Gets the Vault server URL.
Gets a specific configuration value by key.
This delegates to the modern configuration system for better performance and type safety.
Gets multiple configuration values efficiently.
This is more efficient than multiple get_value/2 calls.
@spec ssl_configured?() :: boolean()
Checks if SSL/TLS is properly configured.