Added both a short profile flag '-p' and made the list and update functions optional since not all secret providers need to support them. Also means the default implementation for the list/update functions in the base SecretsProvider trait will error out by default if undefined
This commit is contained in:
+16
-6
@@ -1,21 +1,31 @@
|
||||
pub mod local;
|
||||
mod git_sync;
|
||||
pub mod local;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::providers::local::LocalProvider;
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize};
|
||||
use anyhow::{Result, anyhow};
|
||||
use serde::Deserialize;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
use thiserror::Error;
|
||||
|
||||
pub trait SecretProvider {
|
||||
fn name(&self) -> &'static str;
|
||||
fn name(&self) -> &'static str;
|
||||
fn get_secret(&self, config: &Config, key: &str) -> Result<String>;
|
||||
fn set_secret(&self, config: &Config, key: &str, value: &str) -> Result<()>;
|
||||
fn update_secret(&self, config: &Config, key: &str, value: &str) -> Result<()>;
|
||||
fn update_secret(&self, _config: &Config, _key: &str, _value: &str) -> Result<()> {
|
||||
Err(anyhow!(
|
||||
"update secret not supported for provider {}",
|
||||
self.name()
|
||||
))
|
||||
}
|
||||
fn delete_secret(&self, key: &str) -> Result<()>;
|
||||
fn list_secrets(&self) -> Result<Vec<String>>;
|
||||
fn list_secrets(&self) -> Result<Vec<String>> {
|
||||
Err(anyhow!(
|
||||
"list secrets is not supported for the provider {}",
|
||||
self.name()
|
||||
))
|
||||
}
|
||||
fn sync(&self, config: &mut Config) -> Result<()>;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user