Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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: 6 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added

- Add a `Region::is_default_config` function to determine if a region sticks to the default config ([#983]).

[#983]: https://github.com/stackabletech/operator-rs/pull/983

## [0.87.2] - 2025-03-10

### Changed
Expand Down
25 changes: 19 additions & 6 deletions crates/stackable-operator/src/commons/s3/crd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,31 @@ pub enum S3AccessStyle {
#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Region {
#[serde(default = "default_region_name")]
#[serde(default = "Region::default_region_name")]
pub name: String,
}

/// Having it as `const &str` as well, so we don't always allocate a [`String`] just for comparisons
const DEFAULT_REGION_NAME: &str = "us-east-1";
impl Region {
fn default_region_name() -> String {
DEFAULT_REGION_NAME.to_string()
}

/// Returns if the region sticks to the Stackable defaults.
///
/// Some products don't really support configuring the region.
/// This function can be used to determine if a warning or error should be raised to inform the
/// user of this situation.
pub fn is_default_config(&self) -> bool {
self.name == DEFAULT_REGION_NAME
}
}

impl Default for Region {
fn default() -> Self {
Self {
name: default_region_name(),
name: Self::default_region_name(),
}
}
}

fn default_region_name() -> String {
"us-east-1".into()
}