|
| 1 | +use dockerfile_parser::ImageRef; |
1 | 2 | use k8s_openapi::api::core::v1::LocalObjectReference;
|
2 | 3 | use schemars::JsonSchema;
|
3 | 4 | use serde::{Deserialize, Serialize};
|
@@ -91,12 +92,12 @@ impl ProductImage {
|
91 | 92 |
|
92 | 93 | match &self.image_selection {
|
93 | 94 | ProductImageSelection::Custom(image_selection) => {
|
94 |
| - let image_tag = image_selection |
95 |
| - .custom |
96 |
| - .split_once(':') |
97 |
| - .map_or("latest", |splits| splits.1); |
98 |
| - let app_version_label = |
99 |
| - format!("{}-{}", image_selection.product_version, image_tag); |
| 95 | + let image = ImageRef::parse(&image_selection.custom); |
| 96 | + let app_version_label = format!( |
| 97 | + "{}-{}", |
| 98 | + image_selection.product_version, |
| 99 | + image.tag.unwrap_or("latest".to_string()) |
| 100 | + ); |
100 | 101 | ResolvedProductImage {
|
101 | 102 | product_version: image_selection.product_version.to_string(),
|
102 | 103 | app_version_label,
|
@@ -250,6 +251,36 @@ mod tests {
|
250 | 251 | pull_secrets: None,
|
251 | 252 | }
|
252 | 253 | )]
|
| 254 | + #[case::custom_with_colon_in_repo_and_without_tag( |
| 255 | + "superset", |
| 256 | + "23.7.42", |
| 257 | + r#" |
| 258 | + custom: 127.0.0.1:8080/myteam/stackable/superset |
| 259 | + productVersion: 1.4.1 |
| 260 | + "#, |
| 261 | + ResolvedProductImage { |
| 262 | + image: "127.0.0.1:8080/myteam/stackable/superset".to_string(), |
| 263 | + app_version_label: "1.4.1-latest".to_string(), |
| 264 | + product_version: "1.4.1".to_string(), |
| 265 | + image_pull_policy: "Always".to_string(), |
| 266 | + pull_secrets: None, |
| 267 | + } |
| 268 | + )] |
| 269 | + #[case::custom_with_colon_in_repo_and_with_tag( |
| 270 | + "superset", |
| 271 | + "23.7.42", |
| 272 | + r#" |
| 273 | + custom: 127.0.0.1:8080/myteam/stackable/superset:latest-and-greatest |
| 274 | + productVersion: 1.4.1 |
| 275 | + "#, |
| 276 | + ResolvedProductImage { |
| 277 | + image: "127.0.0.1:8080/myteam/stackable/superset:latest-and-greatest".to_string(), |
| 278 | + app_version_label: "1.4.1-latest-and-greatest".to_string(), |
| 279 | + product_version: "1.4.1".to_string(), |
| 280 | + image_pull_policy: "Always".to_string(), |
| 281 | + pull_secrets: None, |
| 282 | + } |
| 283 | + )] |
253 | 284 | #[case::custom_takes_precedence(
|
254 | 285 | "superset",
|
255 | 286 | "23.7.42",
|
|
0 commit comments