VaultSource

Struct VaultSource 

Source
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

Source

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 Vault
  • vault_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(),
);
Source

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 Vault
  • vault_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(),
);
Source

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

Source§

fn clone(&self) -> VaultSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VaultSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Source for VaultSource

Source§

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.
Source§

fn clone_into_box(&self) -> Box<dyn Source + Send + Sync>

Source§

fn collect_to(&self, cache: &mut Value) -> Result<(), ConfigError>

Collects all configuration properties to a provided cache.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T