diff --git a/rust/agama-server/tests/server_service.rs b/rust/agama-server/tests/server_service.rs index 7367da7972..324f3c6b7e 100644 --- a/rust/agama-server/tests/server_service.rs +++ b/rust/agama-server/tests/server_service.rs @@ -194,7 +194,18 @@ async fn test_put_config_without_mode(ctx: &mut Context) -> Result<(), Box Result<(), Box> for Service { let mut config = message.config.clone().unwrap_or_default(); self.add_kernel_cmdline_defaults(&mut config); + self.add_product_mode(&mut config).await; { let mut state = self.state.write().await; diff --git a/rust/agama-utils/src/products.rs b/rust/agama-utils/src/products.rs index 4ff1a33a7e..6bcb05a045 100644 --- a/rust/agama-utils/src/products.rs +++ b/rust/agama-utils/src/products.rs @@ -63,8 +63,6 @@ pub enum Error { UnknownProduct(String), #[error("Invalid mode '{1}' for product '{0}'")] UnknownMode(String, String), - #[error("Mode required for product '{0}'")] - ModeRequired(String), } /// Products registry. @@ -139,12 +137,15 @@ impl Registry { /// * `id`: product ID. /// * `mode`: product mode. Required only if the product has modes. pub fn find(&self, id: &str, mode: Option<&str>) -> Result { + let mut mode = mode.clone(); let Some(template) = self.products.iter().find(|p| p.id == id) else { return Err(Error::UnknownProduct(id.to_string())); }; - if template.has_modes() && mode.is_none() { - return Err(Error::ModeRequired(id.to_string())); + if mode.is_none() { + if let Some(default_mode) = template.modes.first() { + mode = Some(default_mode.id.as_str()); + } } template.to_product_spec(mode) @@ -539,9 +540,10 @@ mod test { #[test_context(Context)] #[test] - fn test_find_product_with_required_mode(ctx: &mut Context) { - let product = ctx.registry.find("SLES", None).unwrap_err(); - assert!(matches!(product, Error::ModeRequired(_))); + fn test_find_product_without_mode(ctx: &mut Context) { + let product = ctx.registry.find("SLES", None).unwrap(); + assert_eq!(&product.id, "SLES"); + assert_eq!(&product.mode.unwrap(), "standard"); } #[test_context(Context)] diff --git a/rust/package/agama.changes b/rust/package/agama.changes index 156317def4..e6171c94bf 100644 --- a/rust/package/agama.changes +++ b/rust/package/agama.changes @@ -1,4 +1,9 @@ +------------------------------------------------------------------- +Wed Jan 28 16:14:52 UTC 2026 - Imobach Gonzalez Sosa + +- Use the first product mode if none is given (related to jsc#PED-14307). +------------------------------------------------------------------- Wed Jan 28 12:59:50 UTC 2026 - José Iván López González - Add agama-iscsi service and integrate iSCSI into the new HTTP API