Skip to content

refactor: Use ProductImage::product_version internally #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Added `ProductImage::product_version` utility function ([#817], [#818])

### Changed

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

### Fixed

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

## [0.69.3] - 2024-06-12

Expand Down
17 changes: 8 additions & 9 deletions crates/stackable-operator/src/commons/product_image_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ impl ProductImage {
let image_pull_policy = self.pull_policy.as_ref().to_string();
let pull_secrets = self.pull_secrets.clone();

let product_version = self.product_version().to_owned();

match &self.image_selection {
ProductImageSelection::Custom(image_selection) => {
let image = ImageRef::parse(&image_selection.custom);
let image_tag_or_hash = image.tag.or(image.hash).unwrap_or("latest".to_string());
let mut app_version_label =
format!("{}-{}", image_selection.product_version, image_tag_or_hash);
let mut app_version_label = format!("{}-{}", product_version, image_tag_or_hash);
// TODO Use new label mechanism once added
app_version_label.truncate(63);

ResolvedProductImage {
product_version: image_selection.product_version.to_string(),
product_version,
app_version_label,
image: image_selection.custom.clone(),
image_pull_policy,
Expand Down Expand Up @@ -145,14 +146,10 @@ impl ProductImage {
};
let image = format!(
"{repo}/{image_base_name}:{product_version}-stackable{stackable_version}",
product_version = image_selection.product_version,
);
let app_version_label = format!(
"{product_version}-stackable{stackable_version}",
product_version = image_selection.product_version,
);
let app_version_label = format!("{product_version}-stackable{stackable_version}",);
ResolvedProductImage {
product_version: image_selection.product_version.to_string(),
product_version,
app_version_label,
image,
image_pull_policy,
Expand All @@ -163,6 +160,8 @@ impl ProductImage {
}

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