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:
@@ -70,7 +70,7 @@ struct Cli {
|
||||
provider: Option<ProviderKind>,
|
||||
|
||||
/// Specify a run profile to use when wrapping a command
|
||||
#[arg(long)]
|
||||
#[arg(long, short)]
|
||||
profile: Option<String>,
|
||||
|
||||
/// Output the command that will be run instead of executing it
|
||||
@@ -95,7 +95,8 @@ enum Commands {
|
||||
name: String,
|
||||
},
|
||||
|
||||
/// Update an existing secret in the configured secret provider
|
||||
/// Update an existing secret in the configured secret provider (if supported by the provider)
|
||||
/// If a provider does not support updating secrets, this command will return an error.
|
||||
Update {
|
||||
/// Name of the secret to update
|
||||
name: String,
|
||||
|
||||
+15
-5
@@ -1,10 +1,10 @@
|
||||
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;
|
||||
@@ -13,9 +13,19 @@ pub trait SecretProvider {
|
||||
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