@@ -76,30 +76,33 @@ pub struct AutoProductImage {
7676 #[ schemars( with = "Option::<String>" ) ]
7777 stackable_version : Option < semver:: Version > ,
7878
79- /// Use a floating tag for the product image . Defaults to `false `.
79+ /// Configure the Stackable version strategy . Defaults to `Exact `.
8080 ///
81- /// This mechanism utilizes a floating image tag which always refers to the latest patch version
82- /// in the current release line. The current release line is either automatically derived by the
83- /// operator based on its own version, or can be overridden with `stackableVersion`.
81+ /// Currently, two variants are supported:
82+ ///
83+ /// - `Exact`, which uses the exact, fully-qualified, canonical version of a product image.
84+ /// - `LatestPatch`, referencing a floating tag which always points to the latest patch version
85+ /// in the current release line. The current release line is either automatically derived by
86+ /// the operator based on its own version, or can be overridden with `stackableVersion`.
8487 ///
8588 /// A potential newer image is only pulled when Pods are rotated or their containers are
8689 /// restarted. Pods are NOT rotated and containers are NOT restarted automatically when a new
8790 /// image is available. This behaviour makes this a passive update mechanism, rather than an
8891 /// active one.
8992 ///
90- /// It should be noted that when this field is set to `true `, the operator uses `Always` as the
91- /// pull policy for product images. If set to `false `, `IfNotPresent` is used. Explicitly
92- /// setting `pullPolicy` takes precedence.
93+ /// It should be noted that when this field is set to `LatestPatch `, the operator automatically
94+ /// uses `Always` as the pull policy for product images. If set to `Exact `, `IfNotPresent` is
95+ /// used. Explicitly setting `pullPolicy` takes precedence.
9396 ///
9497 /// ### Examples
9598 ///
9699 /// - The `stackableVersion` field is not set, the operator falls back to its own version, eg.
97- /// 26.7.0. If this field is set to `true `, the `26.7` floating tag will be used for product
98- /// images, else, `26.7.0` will be used.
99- /// - The `stackableVersion` field is set to `26.3.0`. If this field is set to `true`, the
100- /// `26.3` floating tag will be used for product images, else, `26.3.0` will be used.
100+ /// 26.7.0. If this field is set to `LatestPatch `, the `26.7` floating tag will be used for
101+ /// product images, else, `26.7.0` will be used.
102+ /// - The `stackableVersion` field is set to `26.3.0`. If this field is set to `LatestPatch`,
103+ /// the `26.3` floating tag will be used for product images, else, `26.3.0` will be used.
101104 #[ serde( default ) ]
102- use_floating_tag : bool ,
105+ stackable_version_strategy : StackableVersionStrategy ,
103106
104107 /// The repository on the container image registry where the container image is located, e.g.
105108 /// `oci.example.com/namespace`.
@@ -233,7 +236,7 @@ impl ProductImage {
233236 ProductImageSelection :: Auto ( AutoProductImage {
234237 stackable_version,
235238 product_version,
236- use_floating_tag ,
239+ stackable_version_strategy ,
237240 repo,
238241 } ) => {
239242 let image_repository = repo
@@ -266,9 +269,10 @@ impl ProductImage {
266269 } ;
267270
268271 // Determine if the selected stackable version is considered floating once.
269- is_floating_tag = stackable_version. is_floating ( ) || * use_floating_tag;
272+ is_floating_tag =
273+ stackable_version. is_floating ( ) || stackable_version_strategy. is_latest_patch ( ) ;
270274
271- let stackable_version = if * use_floating_tag {
275+ let stackable_version = if stackable_version_strategy . is_latest_patch ( ) {
272276 stackable_version. floating ( )
273277 } else {
274278 stackable_version. to_string ( )
@@ -341,6 +345,27 @@ impl ProductImage {
341345 }
342346}
343347
348+ #[ derive( Clone , Debug , Default , Eq , PartialEq , Deserialize , Serialize , JsonSchema ) ]
349+ #[ serde( rename_all = "PascalCase" ) ]
350+ pub enum StackableVersionStrategy {
351+ /// Uses the exact, fully-qualified, canonical version of a product image.
352+ #[ default]
353+ Exact ,
354+
355+ /// Uses the latest patch-level version of a product image.
356+ LatestPatch ,
357+ }
358+
359+ impl StackableVersionStrategy {
360+ pub fn is_exact ( & self ) -> bool {
361+ * self == Self :: Exact
362+ }
363+
364+ pub fn is_latest_patch ( & self ) -> bool {
365+ * self == Self :: LatestPatch
366+ }
367+ }
368+
344369#[ cfg( test) ]
345370mod tests {
346371 use rstest:: rstest;
@@ -458,13 +483,13 @@ mod tests {
458483 pull_secrets: None ,
459484 }
460485 ) ]
461- #[ case:: auto_with_use_floating_tag (
486+ #[ case:: auto_with_stackable_version_policy_latest_patch (
462487 "superset" ,
463488 "oci.stackable.tech/sdp" ,
464489 "23.7.42" ,
465490 r"
466491 productVersion: 1.4.1
467- useFloatingTag: true
492+ stackableVersionStrategy: LatestPatch
468493 " ,
469494 ResolvedProductImage {
470495 image: "oci.stackable.tech/sdp/superset:1.4.1-stackable23.7" . to_owned( ) ,
@@ -474,14 +499,14 @@ mod tests {
474499 pull_secrets: None
475500 }
476501 ) ]
477- #[ case:: auto_with_use_floating_tag_and_stackable_version (
502+ #[ case:: auto_with_stackable_version_policy_latest_patch_and_stackable_version (
478503 "superset" ,
479504 "oci.stackable.tech/sdp" ,
480505 "23.7.42" ,
481506 r"
482507 productVersion: 1.4.1
483508 stackableVersion: 2.1.0
484- useFloatingTag: true
509+ stackableVersionStrategy: LatestPatch
485510 " ,
486511 ResolvedProductImage {
487512 image: "oci.stackable.tech/sdp/superset:1.4.1-stackable2.1" . to_owned( ) ,
@@ -491,14 +516,14 @@ mod tests {
491516 pull_secrets: None
492517 }
493518 ) ]
494- #[ case:: auto_with_use_floating_tag_and_pull_policy (
519+ #[ case:: auto_with_stackable_version_policy_latest_patch_and_pull_policy (
495520 "superset" ,
496521 "oci.stackable.tech/sdp" ,
497522 "23.7.42" ,
498523 r"
499524 productVersion: 1.4.1
500525 pullPolicy: IfNotPresent
501- useFloatingTag: true
526+ stackableVersionStrategy: LatestPatch
502527 " ,
503528 ResolvedProductImage {
504529 image: "oci.stackable.tech/sdp/superset:1.4.1-stackable23.7" . to_owned( ) ,
0 commit comments