Skip to content

Commit

Permalink
Adopt to new ADR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Jul 26, 2023
1 parent 8aac715 commit 14441f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ lazy_static = "1.4.0"
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.4.0" }
rand = "0.8.5"
regex = "1.8.4"
semver = "1.0.18"
schemars = "0.8.12"
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.96"
Expand Down
31 changes: 10 additions & 21 deletions src/commons/product_image_selection.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use k8s_openapi::api::core::v1::LocalObjectReference;
use schemars::JsonSchema;
use semver::Version;
use serde::{Deserialize, Serialize};
use strum::AsRefStr;

use crate::error::{Error, OperatorResult};
use crate::error::OperatorResult;
#[cfg(doc)]
use crate::labels::get_recommended_labels;

Expand Down Expand Up @@ -50,7 +49,7 @@ pub struct ProductImageStackableVersion {
/// Version of the product, e.g. `1.4.1`.
product_version: String,
/// Stackable version of the product, e.g. `23.4`, `23.4.1` or `0.0.0-dev`.
/// If not specified, the operator will use a floating image tag pointing to the latest patch version of this release line, e.g. `23.4`.
/// If not specified, the operator will use its own version, e.g. `23.4.1`.
/// When using a nightly operator it will use the nightly `0.0.0-dev` image.
stackable_version: Option<String>,
/// Name of the docker repo, e.g. `docker.stackable.tech/stackable`
Expand Down Expand Up @@ -88,8 +87,8 @@ pub enum PullPolicy {

impl ProductImage {
/// `image_base_name` should be base of the image name in the container image registry, e.g. `trino`.
/// `operator_version` needs to be the full operator version and needs to be a valid semver string.
/// Accepted values are `23.7.0` or `0.0.0-dev`. Versions with a trailing `-pr` or something else is not supported.
/// `operator_version` needs to be the full operator version and a valid semver string.
/// Accepted values are `23.7.0` or `0.0.0-dev`. Versions with a trailing `-pr` or something else are not supported.
pub fn resolve(
&self,
image_base_name: &str,
Expand Down Expand Up @@ -119,20 +118,10 @@ impl ProductImage {
.repo
.as_deref()
.unwrap_or(STACKABLE_DOCKER_REPO);
let stackable_version = match image_selection.stackable_version.as_ref() {
Some(stackable_version) => stackable_version.to_string(),
None => {
// Nightly and pr versions should use the nightly image
if operator_version == "0.0.0-dev" {
"0.0.0-dev".to_string()
// All other (stable) releases should use the floating tag of the release line
} else {
let operator_version = Version::parse(operator_version)
.map_err(|err| Error::ParseOperatorVersion { source: err })?;
format!("{}.{}", operator_version.major, operator_version.minor)
}
}
};
let stackable_version = image_selection
.stackable_version
.clone()
.unwrap_or(operator_version.to_string());
let image = format!(
"{repo}/{image_base_name}:{product_version}-stackable{stackable_version}",
product_version = image_selection.product_version,
Expand Down Expand Up @@ -166,8 +155,8 @@ mod tests {
productVersion: 1.4.1
"#,
ResolvedProductImage {
image: "docker.stackable.tech/stackable/superset:1.4.1-stackable23.7".to_string(),
app_version_label: "1.4.1-stackable23.7".to_string(),
image: "docker.stackable.tech/stackable/superset:1.4.1-stackable23.7.42".to_string(),
app_version_label: "1.4.1-stackable23.7.42".to_string(),
product_version: "1.4.1".to_string(),
image_pull_policy: "Always".to_string(),
pull_secrets: None,
Expand Down
6 changes: 0 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ pub enum Error {
container_name: String,
violation: String,
},

#[error("failed to parse operator version: {source}")]
ParseOperatorVersion {
#[from]
source: semver::Error,
},
}

pub type OperatorResult<T> = std::result::Result<T, Error>;

0 comments on commit 14441f9

Please sign in to comment.