Skip to content

Commit f949739

Browse files
authored
refactor: Use ProductImage::product_version internally (#818)
* refactor: Use ProductImage::product_version internally * changelog
1 parent f8353ce commit f949739

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

crates/stackable-operator/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Added `ProductImage::product_version` utility function ([#817], [#818])
10+
711
### Changed
812

913
- BREAKING: Bump `kube` to 0.92.0. This required changes in a unit test, because
@@ -13,7 +17,6 @@ All notable changes to this project will be documented in this file.
1317
- [kube#1494](https://github.com/kube-rs/kube/pull/1494)
1418
- [kube#1504](https://github.com/kube-rs/kube/pull/1504)
1519
- Upgrade opentelemetry crates ([#811]).
16-
- Added `ProductImage.product_version()` utility function ([#817])
1720

1821
### Fixed
1922

@@ -23,6 +26,7 @@ All notable changes to this project will be documented in this file.
2326
[#811]: https://github.com/stackabletech/operator-rs/pull/811
2427
[#812]: https://github.com/stackabletech/operator-rs/pull/812
2528
[#817]: https://github.com/stackabletech/operator-rs/pull/817
29+
[#818]: https://github.com/stackabletech/operator-rs/pull/818
2630

2731
## [0.69.3] - 2024-06-12
2832

crates/stackable-operator/src/commons/product_image_selection.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -105,17 +105,18 @@ impl ProductImage {
105105
let image_pull_policy = self.pull_policy.as_ref().to_string();
106106
let pull_secrets = self.pull_secrets.clone();
107107

108+
let product_version = self.product_version().to_owned();
109+
108110
match &self.image_selection {
109111
ProductImageSelection::Custom(image_selection) => {
110112
let image = ImageRef::parse(&image_selection.custom);
111113
let image_tag_or_hash = image.tag.or(image.hash).unwrap_or("latest".to_string());
112-
let mut app_version_label =
113-
format!("{}-{}", image_selection.product_version, image_tag_or_hash);
114+
let mut app_version_label = format!("{}-{}", product_version, image_tag_or_hash);
114115
// TODO Use new label mechanism once added
115116
app_version_label.truncate(63);
116117

117118
ResolvedProductImage {
118-
product_version: image_selection.product_version.to_string(),
119+
product_version,
119120
app_version_label,
120121
image: image_selection.custom.clone(),
121122
image_pull_policy,
@@ -145,14 +146,10 @@ impl ProductImage {
145146
};
146147
let image = format!(
147148
"{repo}/{image_base_name}:{product_version}-stackable{stackable_version}",
148-
product_version = image_selection.product_version,
149-
);
150-
let app_version_label = format!(
151-
"{product_version}-stackable{stackable_version}",
152-
product_version = image_selection.product_version,
153149
);
150+
let app_version_label = format!("{product_version}-stackable{stackable_version}",);
154151
ResolvedProductImage {
155-
product_version: image_selection.product_version.to_string(),
152+
product_version,
156153
app_version_label,
157154
image,
158155
image_pull_policy,
@@ -163,6 +160,8 @@ impl ProductImage {
163160
}
164161

165162
/// The product version is always known without having to resolve the image.
163+
/// In the future we might have a more clever version, which let's the operator pick a recommended product version
164+
/// automatically, e.g. from the LTS release line.
166165
pub fn product_version(&self) -> &str {
167166
match &self.image_selection {
168167
ProductImageSelection::Custom(ProductImageCustom {

0 commit comments

Comments
 (0)