first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+17 -62
View File
@@ -2,29 +2,30 @@
// external secrets from the browser.
#![cfg_attr(target_family = "wasm", allow(dead_code, unused_variables))]
use anyhow::anyhow;
use core::fmt;
use galaxy_util::path::ShellFamily;
use std::path::PathBuf;
use anyhow::anyhow;
pub use cloud_object_models::{ExternalSecret, LastPassSecret, OnePasswordSecret};
use itertools::Itertools;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::path::PathBuf;
#[cfg(all(not(target_family = "wasm"), feature = "local_tty"))]
use crate::terminal::local_shell::execute_command;
use crate::{terminal::shell::ShellType, ui_components::icons::Icon};
use crate::terminal::shell::ShellType;
use crate::ui_components::icons::Icon;
lazy_static! {
// Used as a delimeter to separate metadata (such as names and references)
// in cases the cli tool doesn't display secrets in a common format (i.e. json)
static ref WARP_SECRET_DELIMETER: &'static str = "/warp-secret-delimeter/";
static ref WARP_SECRET_DELIMITER: &'static str = "/warp-secret-delimeter/";
static ref LASTPASS_LIST_SECRETS_COMMAND: Vec<String> = {
vec![
"lpass".to_owned(),
"ls".to_owned(),
format!("--format=%an{}%ai", *WARP_SECRET_DELIMETER),
format!("--format=%an{}%ai", *WARP_SECRET_DELIMITER),
]
};
}
@@ -50,40 +51,6 @@ const LASTPASS_INSTALLED_COMMAND: [&str; 2] = ["lpass", "-v"];
const ONEPASSWORD_DOCS_LINK: &str = "https://developer.1password.com/docs/cli/get-started/";
const LASTPASS_DOCS_LINK: &str = "https://github.com/lastpass/lastpass-cli";
/// Represents a "completed" secret
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum ExternalSecret {
OnePassword(OnePasswordSecret),
LastPass(LastPassSecret),
}
impl ExternalSecret {
pub fn get_secret_extraction_command(&self, shell_family: ShellFamily) -> String {
let prefix = match shell_family {
ShellFamily::Posix => "\\",
ShellFamily::PowerShell => "",
};
match self {
ExternalSecret::OnePassword(secret) => {
format!(
"{}op item get --fields credential --reveal {}",
prefix, secret.reference
)
}
ExternalSecret::LastPass(secret) => {
format!("{}lpass show --password {}", prefix, secret.reference)
}
}
}
pub fn get_display_name(&self) -> String {
match self {
ExternalSecret::OnePassword(secret) => secret.name.clone(),
ExternalSecret::LastPass(secret) => secret.name.clone(),
}
}
}
/// Used to check if a secret manager is installed/fetch list of secrets
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum SecretManager {
@@ -306,10 +273,10 @@ fn parse_onepassword_secrets(output: &str) -> anyhow::Result<Vec<ExternalSecret>
.and_then(|v| v.as_str())
.ok_or(anyhow!("Secret is missing id"))?;
Ok(ExternalSecret::OnePassword(OnePasswordSecret {
name: name.to_string(),
reference: reference.to_string(),
}))
Ok(ExternalSecret::OnePassword(OnePasswordSecret::new(
name.to_string(),
reference.to_string(),
)))
})
.collect::<Result<Vec<_>, anyhow::Error>>()?;
@@ -320,12 +287,12 @@ fn parse_lastpass_secrets(output: &str) -> anyhow::Result<Vec<ExternalSecret>> {
let parsed_output: Vec<ExternalSecret> = output
.lines()
.filter_map(|line| {
let parts = line.split(*WARP_SECRET_DELIMETER).collect_vec();
let parts = line.split(*WARP_SECRET_DELIMITER).collect_vec();
if parts.len() == 2 && !parts[0].is_empty() && !parts[1].is_empty() {
Some(ExternalSecret::LastPass(LastPassSecret {
name: parts[0].to_owned(),
reference: parts[1].to_owned(),
}))
Some(ExternalSecret::LastPass(LastPassSecret::new(
parts[0].to_owned(),
parts[1].to_owned(),
)))
} else {
None
}
@@ -338,15 +305,3 @@ fn parse_lastpass_secrets(output: &str) -> anyhow::Result<Vec<ExternalSecret>> {
Err(anyhow!("Failed to parse any secrets"))
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct OnePasswordSecret {
name: String,
reference: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct LastPassSecret {
name: String,
reference: String,
}