From f66533aa899a224fc16035cee9a2823d6f346b59 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Tue, 6 May 2025 21:17:02 -0400 Subject: [PATCH 01/12] add ingress score --- Cargo.lock | 1 + examples/lamp/Cargo.toml | 1 + examples/lamp/src/main.rs | 9 +++- harmony/src/modules/k8s/ingress.rs | 72 ++++++++++++++++++++++++++++++ harmony/src/modules/k8s/mod.rs | 1 + harmony/src/modules/lamp.rs | 18 ++++++++ 6 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 harmony/src/modules/k8s/ingress.rs diff --git a/Cargo.lock b/Cargo.lock index f84d847..ee85ed7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1032,6 +1032,7 @@ dependencies = [ "harmony_cli", "harmony_macros", "harmony_types", + "k8s-openapi", "log", "tokio", "url", diff --git a/examples/lamp/Cargo.toml b/examples/lamp/Cargo.toml index a433e79..9584ac3 100644 --- a/examples/lamp/Cargo.toml +++ b/examples/lamp/Cargo.toml @@ -16,3 +16,4 @@ harmony_macros = { path = "../../harmony_macros" } log = { workspace = true } env_logger = { workspace = true } url = { workspace = true } +k8s-openapi = { version = "0.24.0", features = ["v1_30"] } diff --git a/examples/lamp/src/main.rs b/examples/lamp/src/main.rs index 06d8534..a027c05 100644 --- a/examples/lamp/src/main.rs +++ b/examples/lamp/src/main.rs @@ -3,12 +3,19 @@ use harmony::{ inventory::Inventory, maestro::Maestro, modules::{ + k8s::{self, ingress::K8sIngressScore, resource::K8sResourceScore}, + { lamp::{LAMPConfig, LAMPScore}, + }, monitoring::monitoring_alerting::MonitoringAlertingStackScore, }, - topology::{K8sAnywhereTopology, Url}, + topology::{K8sAnywhereTopology, Url, k8s::K8sClient}, }; +use k8s_openapi::{ + api::networking::v1::{Ingress, IngressRule, IngressSpec, IngressStatus}, + apimachinery::pkg::apis::meta::v1::ObjectMeta, +}; #[tokio::main] async fn main() { // This here is the whole configuration to diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs new file mode 100644 index 0000000..fb511a7 --- /dev/null +++ b/harmony/src/modules/k8s/ingress.rs @@ -0,0 +1,72 @@ +use k8s_openapi::api::networking::v1::Ingress; +use serde::Serialize; +use serde_json::json; + +use crate::{ + interpret::Interpret, + score::Score, + topology::{K8sclient, Topology}, +}; + +use super::resource::{K8sResourceInterpret, K8sResourceScore}; + +#[derive(Debug, Clone, Serialize)] +pub struct K8sIngressScore { + pub name: String, + pub host: String, + pub backend_service: String, + pub port: String, + pub path: Option, + pub path_type: Option, + pub namespace: Option, +} + +impl Score for K8sIngressScore { + fn create_interpret(&self) -> Box> { + let path = match self.path.clone() { + Some(p) => p, + None => "/".to_string(), + }; + let path_type = match self.path_type.clone() { + Some(p) => p, + None => "Prefix".to_string(), + }; + + let ingress = json!( + { + "metadata": { + "name": self.name + }, + "spec": { + "rules": [ + { "host": self.host, + "http": { + "paths": [ + { + "path": path, + "pathType": path_type, + "backend": [ + { + "service": self.backend_service, + "port": self.port + } + ] + } + ] + } + } + ] + } + } + ); + + let ingress: Ingress = serde_json::from_value(ingress).unwrap(); + Box::new(K8sResourceInterpret { + score: K8sResourceScore::single(ingress.clone(), self.namespace.clone()), + }) + } + + fn name(&self) -> String { + "K8sIngressScore".to_string() + } +} diff --git a/harmony/src/modules/k8s/mod.rs b/harmony/src/modules/k8s/mod.rs index 97e238f..90781f9 100644 --- a/harmony/src/modules/k8s/mod.rs +++ b/harmony/src/modules/k8s/mod.rs @@ -1,3 +1,4 @@ pub mod deployment; +pub mod ingress; pub mod namespace; pub mod resource; diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 637ba92..df38ead 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -13,6 +13,7 @@ use log::{debug, info}; use serde::Serialize; use crate::config::{REGISTRY_PROJECT, REGISTRY_URL}; +use crate::modules::k8s::ingress::K8sIngressScore; use crate::topology::HelmCommand; use crate::{ data::{Id, Version}, @@ -132,6 +133,23 @@ impl Interpret for LAMPInterpret { info!("LAMP deployment_score {deployment_score:?}"); + let lamp_ingress = K8sIngressScore { + name: "lamp-ingress".to_string(), + host: "test".to_string(), + backend_service: "test".to_string(), + port: "8080".to_string(), + path: None, + path_type: None, + namespace: self.get_namespace().map(|nbs| nbs.to_string()), + }; + + lamp_ingress + .create_interpret() + .execute(inventory, topology) + .await?; + + info!("LAMP deployment_score {deployment_score:?}"); + Ok(Outcome::success( "Successfully deployed LAMP Stack!".to_string(), )) -- 2.39.5 From ec767cd9d20154704f1a5da7428fecb70dae469b Mon Sep 17 00:00:00 2001 From: tahahawa Date: Tue, 6 May 2025 21:18:06 -0400 Subject: [PATCH 02/12] remove unneded dep --- examples/lamp/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/lamp/Cargo.toml b/examples/lamp/Cargo.toml index 9584ac3..a433e79 100644 --- a/examples/lamp/Cargo.toml +++ b/examples/lamp/Cargo.toml @@ -16,4 +16,3 @@ harmony_macros = { path = "../../harmony_macros" } log = { workspace = true } env_logger = { workspace = true } url = { workspace = true } -k8s-openapi = { version = "0.24.0", features = ["v1_30"] } -- 2.39.5 From 223c6ffc6d28a57aa23f21ecf10f96ae5e1389ec Mon Sep 17 00:00:00 2001 From: tahahawa Date: Tue, 6 May 2025 21:18:36 -0400 Subject: [PATCH 03/12] fix print --- harmony/src/modules/lamp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index df38ead..f1e3fe8 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -148,7 +148,7 @@ impl Interpret for LAMPInterpret { .execute(inventory, topology) .await?; - info!("LAMP deployment_score {deployment_score:?}"); + info!("LAMP lamp_ingress {lamp_ingress:?}"); Ok(Outcome::success( "Successfully deployed LAMP Stack!".to_string(), -- 2.39.5 From ebde55affd9746b9176cc7616c11dd7703cfe190 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Tue, 6 May 2025 21:20:00 -0400 Subject: [PATCH 04/12] remove reference --- Cargo.lock | 1 - examples/lamp/src/main.rs | 4 ---- 2 files changed, 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee85ed7..f84d847 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1032,7 +1032,6 @@ dependencies = [ "harmony_cli", "harmony_macros", "harmony_types", - "k8s-openapi", "log", "tokio", "url", diff --git a/examples/lamp/src/main.rs b/examples/lamp/src/main.rs index a027c05..a1c124a 100644 --- a/examples/lamp/src/main.rs +++ b/examples/lamp/src/main.rs @@ -12,10 +12,6 @@ use harmony::{ topology::{K8sAnywhereTopology, Url, k8s::K8sClient}, }; -use k8s_openapi::{ - api::networking::v1::{Ingress, IngressRule, IngressSpec, IngressStatus}, - apimachinery::pkg::apis::meta::v1::ObjectMeta, -}; #[tokio::main] async fn main() { // This here is the whole configuration to -- 2.39.5 From 3ca42b30f02049c9101bc7b25202c66c1d5b65c1 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Wed, 14 May 2025 23:26:05 -0400 Subject: [PATCH 05/12] use FQDN which makes sure things conform to RFC 1035, as k8s spec says it should --- Cargo.lock | 17 +++++++++++++++++ harmony/Cargo.toml | 8 ++++++++ harmony/src/modules/k8s/ingress.rs | 10 +++++----- harmony/src/modules/lamp.rs | 9 +++++---- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f84d847..ea6c0c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1172,6 +1172,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fqdn" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f5d7f7b3eed2f771fc7f6fcb651f9560d7b0c483d75876082acb4649d266b3" +dependencies = [ + "punycode", + "serde", +] + [[package]] name = "funty" version = "2.0.0" @@ -1397,6 +1407,7 @@ dependencies = [ "directories", "dockerfile_builder", "env_logger", + "fqdn", "harmony_macros", "harmony_types", "helm-wrapper-rs", @@ -3016,6 +3027,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "punycode" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e1dcb320d6839f6edb64f7a4a59d39b30480d4d1765b56873f7c858538a5fe" + [[package]] name = "quote" version = "1.0.40" diff --git a/harmony/Cargo.toml b/harmony/Cargo.toml index 02a0ce7..a079bd6 100644 --- a/harmony/Cargo.toml +++ b/harmony/Cargo.toml @@ -39,3 +39,11 @@ lazy_static = "1.5.0" dockerfile_builder = "0.1.5" temp-file = "0.1.9" convert_case.workspace = true +fqdn = { version = "0.4.6", features = [ + "domain-label-cannot-start-or-end-with-hyphen", + "domain-label-length-limited-to-63", + "domain-name-without-special-chars", + "domain-name-length-limited-to-255", + "punycode", + "serde", +] } diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs index fb511a7..76fd987 100644 --- a/harmony/src/modules/k8s/ingress.rs +++ b/harmony/src/modules/k8s/ingress.rs @@ -12,10 +12,10 @@ use super::resource::{K8sResourceInterpret, K8sResourceScore}; #[derive(Debug, Clone, Serialize)] pub struct K8sIngressScore { - pub name: String, - pub host: String, - pub backend_service: String, - pub port: String, + pub name: fqdn::FQDN, + pub host: fqdn::FQDN, + pub backend_service: fqdn::FQDN, + pub port: u16, pub path: Option, pub path_type: Option, pub namespace: Option, @@ -67,6 +67,6 @@ impl Score for K8sIngressScore { } fn name(&self) -> String { - "K8sIngressScore".to_string() + format!("{} K8sIngressScore", self.name) } } diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index f1e3fe8..157334c 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -1,6 +1,7 @@ use convert_case::{Case, Casing}; use dockerfile_builder::instruction::{CMD, COPY, ENV, EXPOSE, FROM, RUN, WORKDIR}; use dockerfile_builder::{Dockerfile, instruction_builder::EnvBuilder}; +use fqdn::fqdn; use non_blank_string_rs::NonBlankString; use serde_json::json; use std::collections::HashMap; @@ -134,10 +135,10 @@ impl Interpret for LAMPInterpret { info!("LAMP deployment_score {deployment_score:?}"); let lamp_ingress = K8sIngressScore { - name: "lamp-ingress".to_string(), - host: "test".to_string(), - backend_service: "test".to_string(), - port: "8080".to_string(), + name: fqdn!("lamp-ingress"), + host: fqdn!("test"), + backend_service: fqdn!("test"), + port: 8080, path: None, path_type: None, namespace: self.get_namespace().map(|nbs| nbs.to_string()), -- 2.39.5 From 966fd757bc42a8d7b953699fde8623a8d6d2cdce Mon Sep 17 00:00:00 2001 From: tahahawa Date: Wed, 14 May 2025 23:35:26 -0400 Subject: [PATCH 06/12] try to properly set backend service name --- harmony/src/modules/lamp.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 157334c..2fbb408 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -137,7 +137,11 @@ impl Interpret for LAMPInterpret { let lamp_ingress = K8sIngressScore { name: fqdn!("lamp-ingress"), host: fqdn!("test"), - backend_service: fqdn!("test"), + backend_service: fqdn!( + >::name(&self.score) + .to_case(Case::Kebab) + .as_str() + ), port: 8080, path: None, path_type: None, -- 2.39.5 From 2817939b180b63e1fac60cf48e220c94e72aaae3 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 11:22:35 -0400 Subject: [PATCH 07/12] Create enum for PathType and use FQDN for namespace (RFC 1035 is more strict than RFC 1123, but very similar) --- harmony/src/modules/k8s/ingress.rs | 32 +++++++++++++++++++++++++----- harmony/src/modules/lamp.rs | 4 +++- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs index 76fd987..b7b5a63 100644 --- a/harmony/src/modules/k8s/ingress.rs +++ b/harmony/src/modules/k8s/ingress.rs @@ -10,6 +10,23 @@ use crate::{ use super::resource::{K8sResourceInterpret, K8sResourceScore}; +#[derive(Debug, Clone, Serialize)] +pub enum PathType { + ImplementationSpecific, + Exact, + Prefix, +} + +impl PathType { + fn as_str(&self) -> &'static str { + match self { + PathType::ImplementationSpecific => "ImplementationSpecific", + PathType::Exact => "Exact", + PathType::Prefix => "Prefix", + } + } +} + #[derive(Debug, Clone, Serialize)] pub struct K8sIngressScore { pub name: fqdn::FQDN, @@ -17,8 +34,8 @@ pub struct K8sIngressScore { pub backend_service: fqdn::FQDN, pub port: u16, pub path: Option, - pub path_type: Option, - pub namespace: Option, + pub path_type: Option, + pub namespace: Option, } impl Score for K8sIngressScore { @@ -29,7 +46,7 @@ impl Score for K8sIngressScore { }; let path_type = match self.path_type.clone() { Some(p) => p, - None => "Prefix".to_string(), + None => PathType::Prefix, }; let ingress = json!( @@ -44,7 +61,7 @@ impl Score for K8sIngressScore { "paths": [ { "path": path, - "pathType": path_type, + "pathType": path_type.as_str(), "backend": [ { "service": self.backend_service, @@ -62,7 +79,12 @@ impl Score for K8sIngressScore { let ingress: Ingress = serde_json::from_value(ingress).unwrap(); Box::new(K8sResourceInterpret { - score: K8sResourceScore::single(ingress.clone(), self.namespace.clone()), + score: K8sResourceScore::single( + ingress.clone(), + self.namespace + .clone() + .map(|f| f.as_c_str().to_str().unwrap().to_string()), + ), }) } diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 2fbb408..2c96101 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -145,7 +145,9 @@ impl Interpret for LAMPInterpret { port: 8080, path: None, path_type: None, - namespace: self.get_namespace().map(|nbs| nbs.to_string()), + namespace: self + .get_namespace() + .map(|nbs| fqdn!(nbs.to_string().as_str())), }; lamp_ingress -- 2.39.5 From c4850e79c18cd0e46b974cbb23cfc15b4a06682b Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 12:03:21 -0400 Subject: [PATCH 08/12] Use custom aliased type for ingress path and new macro to check path validity --- examples/lamp/src/main.rs | 3 +-- harmony/src/modules/k8s/ingress.rs | 8 ++++++-- harmony/src/modules/lamp.rs | 3 ++- harmony_macros/src/lib.rs | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/examples/lamp/src/main.rs b/examples/lamp/src/main.rs index a1c124a..ca99d7e 100644 --- a/examples/lamp/src/main.rs +++ b/examples/lamp/src/main.rs @@ -3,13 +3,12 @@ use harmony::{ inventory::Inventory, maestro::Maestro, modules::{ - k8s::{self, ingress::K8sIngressScore, resource::K8sResourceScore}, { lamp::{LAMPConfig, LAMPScore}, }, monitoring::monitoring_alerting::MonitoringAlertingStackScore, }, - topology::{K8sAnywhereTopology, Url, k8s::K8sClient}, + topology::{K8sAnywhereTopology, Url}, }; #[tokio::main] diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs index b7b5a63..37bc38e 100644 --- a/harmony/src/modules/k8s/ingress.rs +++ b/harmony/src/modules/k8s/ingress.rs @@ -1,3 +1,4 @@ +use harmony_macros::k8s_ingress_path; use k8s_openapi::api::networking::v1::Ingress; use serde::Serialize; use serde_json::json; @@ -27,13 +28,15 @@ impl PathType { } } +type K8sIngressPath = String; + #[derive(Debug, Clone, Serialize)] pub struct K8sIngressScore { pub name: fqdn::FQDN, pub host: fqdn::FQDN, pub backend_service: fqdn::FQDN, pub port: u16, - pub path: Option, + pub path: Option, pub path_type: Option, pub namespace: Option, } @@ -42,8 +45,9 @@ impl Score for K8sIngressScore { fn create_interpret(&self) -> Box> { let path = match self.path.clone() { Some(p) => p, - None => "/".to_string(), + None => k8s_ingress_path!("/"), }; + let path_type = match self.path_type.clone() { Some(p) => p, None => PathType::Prefix, diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index 2c96101..bd883e5 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -2,6 +2,7 @@ use convert_case::{Case, Casing}; use dockerfile_builder::instruction::{CMD, COPY, ENV, EXPOSE, FROM, RUN, WORKDIR}; use dockerfile_builder::{Dockerfile, instruction_builder::EnvBuilder}; use fqdn::fqdn; +use harmony_macros::k8s_ingress_path; use non_blank_string_rs::NonBlankString; use serde_json::json; use std::collections::HashMap; @@ -143,7 +144,7 @@ impl Interpret for LAMPInterpret { .as_str() ), port: 8080, - path: None, + path: Some(k8s_ingress_path!("/")), path_type: None, namespace: self .get_namespace() diff --git a/harmony_macros/src/lib.rs b/harmony_macros/src/lib.rs index 2cc4c37..8aded2e 100644 --- a/harmony_macros/src/lib.rs +++ b/harmony_macros/src/lib.rs @@ -116,3 +116,19 @@ pub fn yaml(input: TokenStream) -> TokenStream { } .into() } + +/// Verify that a string is a valid(ish) kubernetes path +/// Panics if path does not start with `/` +#[proc_macro] +pub fn k8s_ingress_path(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as LitStr); + let path_str = input.value(); + + match path_str.starts_with("/") { + true => { + let expanded = quote! {(#path_str.to_string()) }; + return TokenStream::from(expanded); + } + false => panic!("Invalid k8s path"), + } +} -- 2.39.5 From 1d6cc670df28508432eb231dcd6b13d56224d47e Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 12:03:56 -0400 Subject: [PATCH 09/12] update panic message --- harmony_macros/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/harmony_macros/src/lib.rs b/harmony_macros/src/lib.rs index 8aded2e..ce28363 100644 --- a/harmony_macros/src/lib.rs +++ b/harmony_macros/src/lib.rs @@ -129,6 +129,6 @@ pub fn k8s_ingress_path(input: TokenStream) -> TokenStream { let expanded = quote! {(#path_str.to_string()) }; return TokenStream::from(expanded); } - false => panic!("Invalid k8s path"), + false => panic!("Invalid k8s ingress path"), } } -- 2.39.5 From 54820099482b112151b8a376a291265f8f97f852 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 12:07:13 -0400 Subject: [PATCH 10/12] rename k8s ingress path macro --- harmony/src/modules/k8s/ingress.rs | 4 ++-- harmony/src/modules/lamp.rs | 4 ++-- harmony_macros/src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs index 37bc38e..ca84edf 100644 --- a/harmony/src/modules/k8s/ingress.rs +++ b/harmony/src/modules/k8s/ingress.rs @@ -1,4 +1,4 @@ -use harmony_macros::k8s_ingress_path; +use harmony_macros::ingress_path; use k8s_openapi::api::networking::v1::Ingress; use serde::Serialize; use serde_json::json; @@ -45,7 +45,7 @@ impl Score for K8sIngressScore { fn create_interpret(&self) -> Box> { let path = match self.path.clone() { Some(p) => p, - None => k8s_ingress_path!("/"), + None => ingress_path!("/"), }; let path_type = match self.path_type.clone() { diff --git a/harmony/src/modules/lamp.rs b/harmony/src/modules/lamp.rs index bd883e5..3c5c439 100644 --- a/harmony/src/modules/lamp.rs +++ b/harmony/src/modules/lamp.rs @@ -2,7 +2,7 @@ use convert_case::{Case, Casing}; use dockerfile_builder::instruction::{CMD, COPY, ENV, EXPOSE, FROM, RUN, WORKDIR}; use dockerfile_builder::{Dockerfile, instruction_builder::EnvBuilder}; use fqdn::fqdn; -use harmony_macros::k8s_ingress_path; +use harmony_macros::ingress_path; use non_blank_string_rs::NonBlankString; use serde_json::json; use std::collections::HashMap; @@ -144,7 +144,7 @@ impl Interpret for LAMPInterpret { .as_str() ), port: 8080, - path: Some(k8s_ingress_path!("/")), + path: Some(ingress_path!("/")), path_type: None, namespace: self .get_namespace() diff --git a/harmony_macros/src/lib.rs b/harmony_macros/src/lib.rs index ce28363..4b5132e 100644 --- a/harmony_macros/src/lib.rs +++ b/harmony_macros/src/lib.rs @@ -120,7 +120,7 @@ pub fn yaml(input: TokenStream) -> TokenStream { /// Verify that a string is a valid(ish) kubernetes path /// Panics if path does not start with `/` #[proc_macro] -pub fn k8s_ingress_path(input: TokenStream) -> TokenStream { +pub fn ingress_path(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as LitStr); let path_str = input.value(); -- 2.39.5 From 9418f3b964623eed99aec454c9c1d3ec2cfaff81 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 12:09:02 -0400 Subject: [PATCH 11/12] update panic message/docstring --- harmony_macros/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/harmony_macros/src/lib.rs b/harmony_macros/src/lib.rs index 4b5132e..7e9ee47 100644 --- a/harmony_macros/src/lib.rs +++ b/harmony_macros/src/lib.rs @@ -117,7 +117,7 @@ pub fn yaml(input: TokenStream) -> TokenStream { .into() } -/// Verify that a string is a valid(ish) kubernetes path +/// Verify that a string is a valid(ish) ingress path /// Panics if path does not start with `/` #[proc_macro] pub fn ingress_path(input: TokenStream) -> TokenStream { @@ -129,6 +129,6 @@ pub fn ingress_path(input: TokenStream) -> TokenStream { let expanded = quote! {(#path_str.to_string()) }; return TokenStream::from(expanded); } - false => panic!("Invalid k8s ingress path"), + false => panic!("Invalid ingress path"), } } -- 2.39.5 From 0eb63f2425f1f8104a042d64d0eae52e8561ece7 Mon Sep 17 00:00:00 2001 From: tahahawa Date: Thu, 15 May 2025 12:10:00 -0400 Subject: [PATCH 12/12] K8sIngressPath --- harmony/src/modules/k8s/ingress.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/harmony/src/modules/k8s/ingress.rs b/harmony/src/modules/k8s/ingress.rs index ca84edf..883d721 100644 --- a/harmony/src/modules/k8s/ingress.rs +++ b/harmony/src/modules/k8s/ingress.rs @@ -28,7 +28,7 @@ impl PathType { } } -type K8sIngressPath = String; +type IngressPath = String; #[derive(Debug, Clone, Serialize)] pub struct K8sIngressScore { @@ -36,7 +36,7 @@ pub struct K8sIngressScore { pub host: fqdn::FQDN, pub backend_service: fqdn::FQDN, pub port: u16, - pub path: Option, + pub path: Option, pub path_type: Option, pub namespace: Option, } -- 2.39.5