From 8c94473ae39233dd9c31ad7085c0deb245ed29c0 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sun, 8 Sep 2024 09:39:38 -0400 Subject: [PATCH] fix: Ensure image names are lowercase --- process/drivers/github_driver.rs | 4 +++- process/drivers/traits.rs | 19 ++++++++++++++++--- test-files/github-events/branch.json | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/process/drivers/github_driver.rs b/process/drivers/github_driver.rs index a86b6016..6bb3f341 100644 --- a/process/drivers/github_driver.rs +++ b/process/drivers/github_driver.rs @@ -123,7 +123,9 @@ impl CiDriver for GithubDriver { .repository .owner .login - )) + ) + .trim() + .to_lowercase()) } } diff --git a/process/drivers/traits.rs b/process/drivers/traits.rs index 1bd09841..3f0db119 100644 --- a/process/drivers/traits.rs +++ b/process/drivers/traits.rs @@ -330,13 +330,26 @@ pub trait CiDriver { fn inner(opts: &GenerateImageNameOpts, driver_registry: &str) -> Result { let image = match (&opts.registry, &opts.registry_namespace) { (Some(registry), Some(registry_namespace)) => { - format!("{registry}/{registry_namespace}/{}", &opts.name) + format!( + "{}/{}/{}", + registry.trim().to_lowercase(), + registry_namespace.trim().to_lowercase(), + opts.name.trim().to_lowercase() + ) } (Some(registry), None) => { - format!("{registry}/{}", &opts.name) + format!( + "{}/{}", + registry.trim().to_lowercase(), + opts.name.trim().to_lowercase() + ) } _ => { - format!("{}/{}", driver_registry, &opts.name) + format!( + "{}/{}", + driver_registry.trim().to_lowercase(), + opts.name.trim().to_lowercase() + ) } }; image diff --git a/test-files/github-events/branch.json b/test-files/github-events/branch.json index 99e28cb3..f65c9a5e 100644 --- a/test-files/github-events/branch.json +++ b/test-files/github-events/branch.json @@ -3,7 +3,7 @@ "repository": { "default_branch": "main", "owner": { - "login": "test-owner" + "login": "Test-Owner" }, "html_url": "https://example.com/" }