From 90342a4ccc0b223b59f7d8d0732f601739476673 Mon Sep 17 00:00:00 2001 From: jamesgiu Date: Sat, 19 Apr 2025 10:56:07 +1000 Subject: [PATCH 1/2] QK-XX fix deployment matcher panic: --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 58a0566..3b3c3df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,7 +62,10 @@ fn find_matching_pod(matcher: &str) -> Result { let deployments = String::from_utf8(deployment_output.stdout).unwrap().to_string(); - re = Regex::new(&format!(r".*{matcher}.*[A-Za-z]+ ")).unwrap(); + // Strip numbers and dashes from the matcher + let sanitised_matcher = Regex::new(r"\-*[0-9]*").unwrap().replace_all(matcher, ""); + + re = Regex::new(&format!(r".*{sanitised_matcher}.*[A-Za-z]* ")).unwrap(); let Some(deployment_matches): Option = re.captures(&*deployments) else { todo!() }; From 44fbb0a872872f396c2946007452825e1bdf9361 Mon Sep 17 00:00:00 2001 From: jamesgiu Date: Sat, 19 Apr 2025 18:11:03 +1000 Subject: [PATCH 2/2] QK-XX fix regex --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3b3c3df..aaf2651 100644 --- a/src/main.rs +++ b/src/main.rs @@ -63,9 +63,9 @@ fn find_matching_pod(matcher: &str) -> Result { let deployments = String::from_utf8(deployment_output.stdout).unwrap().to_string(); // Strip numbers and dashes from the matcher - let sanitised_matcher = Regex::new(r"\-*[0-9]*").unwrap().replace_all(matcher, ""); + let sanitised_matcher = Regex::new(r"\-+[0-9]+").unwrap().replace_all(matcher, ""); - re = Regex::new(&format!(r".*{sanitised_matcher}.*[A-Za-z]* ")).unwrap(); + re = Regex::new(&format!(r"[A-Za-z-]*{sanitised_matcher}[A-Za-z-]* ")).unwrap(); let Some(deployment_matches): Option = re.captures(&*deployments) else { todo!() };