From f180cc4c80945399420029624ae7c881ab7da299 Mon Sep 17 00:00:00 2001 From: Ian Letourneau Date: Thu, 28 Aug 2025 14:29:24 -0400 Subject: [PATCH] wip: rename harmony-secret* by harmony_secret* --- Cargo.lock | 63 +++++++++++++++++--------------- examples/okd_pxe/Cargo.toml | 3 ++ examples/okd_pxe/src/main.rs | 2 +- examples/okd_pxe/src/topology.rs | 19 +++++++++- harmony/Cargo.toml | 2 +- harmony_secret/Cargo.toml | 4 +- harmony_secret_derive/Cargo.toml | 2 +- harmony_secret_derive/src/lib.rs | 4 +- 8 files changed, 61 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index befd87e..e7438fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1716,8 +1716,11 @@ dependencies = [ "harmony", "harmony_cli", "harmony_macros", + "harmony_secret", + "harmony_secret_derive", "harmony_types", "log", + "serde", "tokio", "url", ] @@ -2125,8 +2128,8 @@ dependencies = [ "env_logger", "fqdn", "futures-util", - "harmony-secret-derive", "harmony_macros", + "harmony_secret_derive", "harmony_types", "helm-wrapper-rs", "hex", @@ -2166,35 +2169,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "harmony-secret" -version = "0.1.0" -dependencies = [ - "async-trait", - "directories", - "harmony-secret-derive", - "http 1.3.1", - "infisical", - "lazy_static", - "log", - "pretty_assertions", - "serde", - "serde_json", - "tempfile", - "thiserror 2.0.14", - "tokio", -] - -[[package]] -name = "harmony-secret-derive" -version = "0.1.0" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "harmony_cli" version = "0.1.0" @@ -2259,6 +2233,35 @@ dependencies = [ "syn", ] +[[package]] +name = "harmony_secret" +version = "0.1.0" +dependencies = [ + "async-trait", + "directories", + "harmony_secret_derive", + "http 1.3.1", + "infisical", + "lazy_static", + "log", + "pretty_assertions", + "serde", + "serde_json", + "tempfile", + "thiserror 2.0.14", + "tokio", +] + +[[package]] +name = "harmony_secret_derive" +version = "0.1.0" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "harmony_tui" version = "0.1.0" diff --git a/examples/okd_pxe/Cargo.toml b/examples/okd_pxe/Cargo.toml index 609432e..23f3cf4 100644 --- a/examples/okd_pxe/Cargo.toml +++ b/examples/okd_pxe/Cargo.toml @@ -10,6 +10,8 @@ publish = false harmony = { path = "../../harmony" } harmony_cli = { path = "../../harmony_cli" } harmony_types = { path = "../../harmony_types" } +harmony_secret = { path = "../../harmony_secret" } +harmony_secret_derive = { path = "../../harmony_secret_derive" } cidr = { workspace = true } tokio = { workspace = true } harmony_macros = { path = "../../harmony_macros" } @@ -17,3 +19,4 @@ log = { workspace = true } env_logger = { workspace = true } url = { workspace = true } askama = "0.14.0" +serde.workspace = true diff --git a/examples/okd_pxe/src/main.rs b/examples/okd_pxe/src/main.rs index 7f0c09d..0267a0d 100644 --- a/examples/okd_pxe/src/main.rs +++ b/examples/okd_pxe/src/main.rs @@ -22,7 +22,7 @@ async fn main() { let cluster_pubkey_filename = "cluster_ssh_key.pub"; let harmony_inventory_agent = "harmony_inventory_agent"; - // TODO this should be a single IPXEScore instead of having the user do this step by step + // TODO: this should be a single IPXEScore instead of having the user do this step by step let scores: Vec>> = vec![ Box::new(DhcpScore { host_binding: vec![], diff --git a/examples/okd_pxe/src/topology.rs b/examples/okd_pxe/src/topology.rs index 90ba195..198226c 100644 --- a/examples/okd_pxe/src/topology.rs +++ b/examples/okd_pxe/src/topology.rs @@ -8,6 +8,14 @@ use harmony::{ topology::{HAClusterTopology, LogicalHost, UnmanagedRouter}, }; use harmony_macros::{ip, ipv4}; +use harmony_secret::{Secret, SecretManager}; +use serde::{Deserialize, Serialize}; + +#[derive(Secret, Serialize, Deserialize, Debug, PartialEq)] +struct OPNSenseFirewallConfig { + username: String, + password: String, +} pub async fn get_topology() -> HAClusterTopology { let firewall = harmony::topology::LogicalHost { @@ -15,8 +23,17 @@ pub async fn get_topology() -> HAClusterTopology { name: String::from("opnsense-1"), }; + let config = SecretManager::get::().await; + let config = config.unwrap(); + let opnsense = Arc::new( - harmony::infra::opnsense::OPNSenseFirewall::new(firewall, None, "root", "opnsense").await, + harmony::infra::opnsense::OPNSenseFirewall::new( + firewall, + None, + &config.username, + &config.password, + ) + .await, ); let lan_subnet = ipv4!("192.168.1.0"); let gateway_ipv4 = ipv4!("192.168.1.1"); diff --git a/harmony/Cargo.toml b/harmony/Cargo.toml index 1ba4c94..fc568ab 100644 --- a/harmony/Cargo.toml +++ b/harmony/Cargo.toml @@ -67,7 +67,7 @@ bollard.workspace = true tar.workspace = true base64.workspace = true once_cell = "1.21.3" -harmony-secret-derive = { version = "0.1.0", path = "../harmony_secret_derive" } +harmony_secret_derive = { version = "0.1.0", path = "../harmony_secret_derive" } [dev-dependencies] pretty_assertions.workspace = true diff --git a/harmony_secret/Cargo.toml b/harmony_secret/Cargo.toml index 48c8f5c..c08d0b0 100644 --- a/harmony_secret/Cargo.toml +++ b/harmony_secret/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "harmony-secret" +name = "harmony_secret" edition = "2024" version.workspace = true readme.workspace = true license.workspace = true [dependencies] -harmony-secret-derive = { version = "0.1.0", path = "../harmony_secret_derive" } +harmony_secret_derive = { version = "0.1.0", path = "../harmony_secret_derive" } serde = { version = "1.0.209", features = ["derive", "rc"] } serde_json = "1.0.127" thiserror.workspace = true diff --git a/harmony_secret_derive/Cargo.toml b/harmony_secret_derive/Cargo.toml index 5d24b72..7142c27 100644 --- a/harmony_secret_derive/Cargo.toml +++ b/harmony_secret_derive/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "harmony-secret-derive" +name = "harmony_secret_derive" version = "0.1.0" edition = "2024" diff --git a/harmony_secret_derive/src/lib.rs b/harmony_secret_derive/src/lib.rs index 8aa83df..71822af 100644 --- a/harmony_secret_derive/src/lib.rs +++ b/harmony_secret_derive/src/lib.rs @@ -10,10 +10,10 @@ pub fn derive_secret(input: TokenStream) -> TokenStream { // The key for the secret will be the stringified name of the struct itself. // e.g., `struct OKDClusterSecret` becomes key `"OKDClusterSecret"`. - let key = struct_ident.to_string(); + let key = struct_ident.to_string(); // TODO: Utiliser path complet de la struct // Find the path to the `harmony_secret` crate. - let secret_crate_path = match crate_name("harmony-secret") { + let secret_crate_path = match crate_name("harmony_secret") { Ok(FoundCrate::Itself) => quote!(crate), Ok(FoundCrate::Name(name)) => { let ident = Ident::new(&name, proc_macro2::Span::call_site());