mirror of
https://codeberg.org/spire/dispenser.git
synced 2026-06-04 02:24:07 +02:00
use secretfile
This commit is contained in:
parent
c00b7b4ab8
commit
715be91a73
3 changed files with 169 additions and 148 deletions
|
|
@ -2,6 +2,7 @@ use crate::cloud::digitalocean::DigitalOcean;
|
|||
use crate::cloud::vultr::Vultr;
|
||||
use crate::cloud::Cloud;
|
||||
use camino::Utf8PathBuf;
|
||||
use secretfile::{load, SecretError};
|
||||
use serde::de::Error;
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use std::fs::read_to_string;
|
||||
|
|
@ -84,11 +85,9 @@ where
|
|||
load_secret(raw).map_err(D::Error::custom)
|
||||
}
|
||||
|
||||
fn load_secret(raw: String) -> Result<String, std::io::Error> {
|
||||
let path: &Path = raw.as_ref();
|
||||
if raw.starts_with('/') && path.exists() {
|
||||
let raw = read_to_string(raw)?;
|
||||
Ok(raw.trim().into())
|
||||
fn load_secret(raw: String) -> Result<String, SecretError> {
|
||||
if raw.starts_with('/') || raw.starts_with('$') {
|
||||
load(&raw)
|
||||
} else {
|
||||
Ok(raw)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue