Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e76654e

Browse files
authoredOct 31, 2023
Merge branch 'main' into refactor/product-config-errors
2 parents ca2104d + 496baab commit e76654e

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed
 

‎CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ All notable changes to this project will be documented in this file.
1212

1313
- BREAKING: Rename `product_logging::framework::shutdown_vector_command` to `create_vector_shutdown_file_command` and added `remove_vector_shutdown_file_command` ([#681]).
1414

15+
### Fixed
16+
17+
- Fix Docker image tag parsing when user specifies custom image ([#677]).
18+
19+
[#677]: https://github.com/stackabletech/operator-rs/pull/677
1520
[#681]: https://github.com/stackabletech/operator-rs/pull/681
1621

1722
## [0.55.0] - 2023-10-16

‎Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ chrono = { version = "0.4.26", default-features = false }
2222
clap = { version = "4.3.19", features = ["derive", "cargo", "env"] }
2323
const_format = "0.2.31"
2424
derivative = "2.2.0"
25+
dockerfile-parser = "0.8.0"
2526
either = "1.9.0"
2627
futures = "0.3.28"
2728
json-patch = "1.0.0"

‎src/commons/product_image_selection.rs

+37-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use dockerfile_parser::ImageRef;
12
use k8s_openapi::api::core::v1::LocalObjectReference;
23
use schemars::JsonSchema;
34
use serde::{Deserialize, Serialize};
@@ -91,12 +92,12 @@ impl ProductImage {
9192

9293
match &self.image_selection {
9394
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+
);
100101
ResolvedProductImage {
101102
product_version: image_selection.product_version.to_string(),
102103
app_version_label,
@@ -250,6 +251,36 @@ mod tests {
250251
pull_secrets: None,
251252
}
252253
)]
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+
)]
253284
#[case::custom_takes_precedence(
254285
"superset",
255286
"23.7.42",

0 commit comments

Comments
 (0)
Please sign in to comment.