From 3016c878c831e7cbdea79874d2b7ab2de2e0c809 Mon Sep 17 00:00:00 2001 From: Ermin Hrkalovic Date: Mon, 9 Mar 2026 17:48:43 +0100 Subject: [PATCH] add arch as an option paramater for the naming template Signed-off-by: Ermin Hrkalovic --- core-dump-composer/src/config.rs | 15 +++++++++++++++ core-dump-composer/src/events.rs | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/core-dump-composer/src/config.rs b/core-dump-composer/src/config.rs index 921609f..d978db2 100644 --- a/core-dump-composer/src/config.rs +++ b/core-dump-composer/src/config.rs @@ -47,6 +47,7 @@ pub struct CoreParams { pub namespace: Option, pub podname: Option, pub uuid: Uuid, + pub arch: String, } static DEFAULT_TEMPLATE: &str = "{uuid}-dump-{timestamp}-{hostname}-{exe_name}-{pid}-{signal}"; @@ -64,6 +65,7 @@ impl CoreConfig { let pathname = matches.value_of("pathname").unwrap_or("").to_string(); let uuid = Uuid::new_v4(); + let arch = std::env::consts::ARCH.to_string(); let params = CoreParams { limit_size, @@ -77,6 +79,7 @@ impl CoreConfig { namespace: None, podname: None, uuid, + arch }; let mut dot_env_path = env::current_exe()?; @@ -376,6 +379,18 @@ mod tests { assert_eq!(just_namespace, "anamespace".to_string()); } #[test] + fn arch_is_rendered() { + let mut config = match CoreConfig::new() { + Ok(v) => v, + Err(e) => panic!("Generation of CoreConfig failed. {}", e), + }; + let templated_name = config.get_templated_name(); + assert!(templated_name.contains("-dump-----")); + config.filename_template = "{arch}".to_string(); + let just_arch = config.get_templated_name(); + assert_eq!(just_arch, std::env::consts::ARCH); + } + #[test] fn default_template_test() { // "{uuid}-dump-{timestamp}-{hostname}-{exe_name}-{pid}-{signal}"; let mut config = match CoreConfig::new() { diff --git a/core-dump-composer/src/events.rs b/core-dump-composer/src/events.rs index 82bae9c..ebdbd1f 100644 --- a/core-dump-composer/src/events.rs +++ b/core-dump-composer/src/events.rs @@ -154,6 +154,7 @@ mod tests { let pathname = "pathname".to_string(); let uuid = Uuid::new_v4(); let podname = "podname".to_string(); + let arch = "arch".to_string(); let params = CoreParams { limit_size, @@ -167,6 +168,7 @@ mod tests { namespace: None, uuid, podname: Some(podname), + arch }; let pod = json!( { @@ -236,6 +238,7 @@ mod tests { let pathname = "pathname".to_string(); let uuid = Uuid::new_v4(); let podname = "podname".to_string(); + let arch = "arch".to_string(); let params = CoreParams { limit_size, @@ -249,6 +252,7 @@ mod tests { namespace: None, uuid, podname: Some(podname), + arch }; let image1 = json!({ "id": "sha256:3b8adc6c30f4e7e4afb57daef9d1c8af783a4a647a4670780e9df085c0525efa",