d68f003000
CI / Change detection (push) Has been cancelled
CI / Version drift (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Workflow RLM cache (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / npm wrapper smoke (push) Has been cancelled
CI / Mobile runtime smoke (push) Has been cancelled
CI / Workflow lint (push) Has been cancelled
CI / Documentation (push) Has been cancelled
Web Frontend / Lint & Type Check (push) Failing after 1s
Auto-close harvested PRs / close (push) Failing after 1s
cargo-deny / cargo-deny (bans licenses sources) (push) Failing after 1s
Security audit / cargo-audit (push) Failing after 1s
Sync to CNB / sync (push) Failing after 1s
cargo-deny / cargo-deny (advisories) (push) Failing after 3s
Web Frontend / Deploy to Cloudflare (push) Has been cancelled
56 lines
1.7 KiB
Rust
56 lines
1.7 KiB
Rust
use anyhow::{Result, bail};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum AuthSourceKind {
|
|
Command,
|
|
Secret,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(deny_unknown_fields)]
|
|
pub struct ProviderAuthSourceToml {
|
|
#[serde(alias = "type")]
|
|
pub source: AuthSourceKind,
|
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
|
pub command: Vec<String>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub timeout_ms: Option<u64>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub secret_id: Option<String>,
|
|
}
|
|
|
|
impl ProviderAuthSourceToml {
|
|
pub fn validate(&self) -> Result<()> {
|
|
match self.source {
|
|
AuthSourceKind::Command => {
|
|
if self.command.is_empty() || self.command.iter().all(|part| part.trim().is_empty())
|
|
{
|
|
bail!(
|
|
"provider auth source command must include at least one non-empty argv item"
|
|
);
|
|
}
|
|
}
|
|
AuthSourceKind::Secret => {
|
|
if self
|
|
.secret_id
|
|
.as_deref()
|
|
.is_none_or(|secret_id| secret_id.trim().is_empty())
|
|
{
|
|
bail!("provider auth source secret must include secret_id");
|
|
}
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[must_use]
|
|
pub fn source_class(&self) -> &'static str {
|
|
match self.source {
|
|
AuthSourceKind::Command => "command",
|
|
AuthSourceKind::Secret => "secret",
|
|
}
|
|
}
|
|
}
|