pub struct SecretRef {
pub env: Option<String>,
pub file: Option<String>,
pub cmd: Option<String>,
}Expand description
A reference to a secret — never the secret itself.
Exactly one of the three sources is set per entry:
[agent-identity.tokens]
from_env = { env = "SOME_TOKEN" } # read $SOME_TOKEN
from_file = { file = "~/.secrets/tok" } # first non-empty line
from_cmd = { cmd = "pass show ci/token" } # stdout of the commandThis is the same secret-by-reference shape as
crate::config::BackendConfig::resolve_api_key (env-or-file), extended
with a cmd source for secret managers (pass, vault, op, …).
Fields§
§env: Option<String>Environment variable to read the secret from.
file: Option<String>File whose first non-empty line is the secret (tilde-expanded).
cmd: Option<String>Shell command whose trimmed stdout is the secret.
Implementations§
Source§impl SecretRef
impl SecretRef
Sourcepub fn resolve(&self) -> Result<Option<Secret>>
pub fn resolve(&self) -> Result<Option<Secret>>
Resolve this reference to its Secret value.
Source precedence when more than one is set: env → file → cmd.
Returns Ok(None) when the configured source resolves to nothing
(missing env var / empty file) and Err only when a configured cmd
fails to execute or exits non-zero — a misconfiguration the caller
should see rather than silently treat as “no token”.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SecretRef
impl<'de> Deserialize<'de> for SecretRef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for SecretRef
impl StructuralPartialEq for SecretRef
Auto Trait Implementations§
impl Freeze for SecretRef
impl RefUnwindSafe for SecretRef
impl Send for SecretRef
impl Sync for SecretRef
impl Unpin for SecretRef
impl UnsafeUnpin for SecretRef
impl UnwindSafe for SecretRef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more