pub struct VaultSource { /* private fields */ }Expand description
A Source for the config library that loads configurations from HashiCorp Vault.
This source connects to a HashiCorp Vault server and loads a secret from the version 2 of the KV (Key-Value) engine. The values from the secret are included in the configuration as flat key-value pairs.
§Example
use config_vault::VaultSource;
let vault = VaultSource::new(
"http://vault.example.com:8200".to_string(),
"my-token".to_string(),
"secret".to_string(),
"dev".to_string(),
);Implementations§
Source§impl VaultSource
impl VaultSource
Sourcepub fn new(
vault_addr: String,
vault_token: String,
vault_mount: String,
vault_path: String,
) -> Self
pub fn new( vault_addr: String, vault_token: String, vault_mount: String, vault_path: String, ) -> Self
Creates a new instance of VaultSource.
§Parameters
vault_addr- Complete URL of the Vault server (e.g. “http://127.0.0.1:8200”)vault_token- Authentication token for Vaultvault_mount- Name of the KV engine mount (e.g. “secret”)vault_path- Path to the secret within the mount (e.g. “dev”)
§Example
use config_vault::VaultSource;
let source = VaultSource::new(
"http://127.0.0.1:8200".to_string(),
"hvs.EXAMPLE_TOKEN".to_string(),
"secret".to_string(),
"dev".to_string(),
);Sourcepub fn new_v1(
vault_addr: String,
vault_token: String,
vault_mount: String,
vault_path: String,
) -> Self
pub fn new_v1( vault_addr: String, vault_token: String, vault_mount: String, vault_path: String, ) -> Self
Creates a new instance of VaultSource with kv_version V1
§Parameters
vault_addr- Complete URL of the Vault server (e.g. “http://127.0.0.1:8200”)vault_token- Authentication token for Vaultvault_mount- Name of the KV engine mount (e.g. “secret”)vault_path- Path to the secret within the mount (e.g. “dev”)
§Example
use config_vault::VaultSource;
let source = VaultSource::new_v1(
"http://127.0.0.1:8200".to_string(),
"hvs.EXAMPLE_TOKEN".to_string(),
"secret".to_string(),
"dev".to_string(),
);Sourcepub fn set_kv_version(&mut self, kv_version: KvVersion)
pub fn set_kv_version(&mut self, kv_version: KvVersion)
Changes the KvVersion
This function takes the target KvVersion and replaces the existing one.
Trait Implementations§
Source§impl Clone for VaultSource
impl Clone for VaultSource
Source§fn clone(&self) -> VaultSource
fn clone(&self) -> VaultSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VaultSource
impl Debug for VaultSource
Source§impl Source for VaultSource
impl Source for VaultSource
Source§fn collect(&self) -> Result<Map<String, Value>, ConfigError>
fn collect(&self) -> Result<Map<String, Value>, ConfigError>
Implementation of the collect method from Source.
This method makes an HTTP request to the Vault API to obtain configuration values stored in the specified secret.
§Returns
Result<Map<String, Value>, ConfigError>- A map with configuration values or an error if the request fails or the response format is not as expected.
fn clone_into_box(&self) -> Box<dyn Source + Send + Sync>
Source§fn collect_to(&self, cache: &mut Value) -> Result<(), ConfigError>
fn collect_to(&self, cache: &mut Value) -> Result<(), ConfigError>
Collects all configuration properties to a provided cache.
Auto Trait Implementations§
impl Freeze for VaultSource
impl RefUnwindSafe for VaultSource
impl Send for VaultSource
impl Sync for VaultSource
impl Unpin for VaultSource
impl UnwindSafe for VaultSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more