diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 391ddd06..430f1344 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file. [CVE-2024-45311] ([#318]). - Bump Rust toolchain version to 1.80.1 ([#318]). +### Fixed + +- Sort operator versions by semver version instead of alphabetically ([#XXX]). + [#318]: https://github.com/stackabletech/stackable-cockpit/pull/318 [CVE-2024-45311]: https://github.com/advisories/GHSA-vr26-jcq5-fjj8 diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 28ca2cad..7328d03d 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -130,6 +130,12 @@ pub enum CmdError { #[snafu(display("invalid repository name"))] InvalidRepoName { source: InvalidRepoNameError }, + #[snafu(display("invalid helm chart version {version:?}"))] + InvalidHelmChartVersion { + source: semver::Error, + version: String, + }, + #[snafu(display("unknown repository name '{name}'"))] UnknownRepoName { name: String }, @@ -524,16 +530,15 @@ where Some(entries) => { let mut versions = entries .iter() - .map(|e| Version::parse(&e.version)) - .map_while(|r| match r { - Ok(v) => Some(v), - Err(_) => None, + .map(|entry| { + Version::parse(&entry.version).context(InvalidHelmChartVersionSnafu { + version: entry.version.clone(), + }) }) - .map(|v| v.to_string()) - .collect::>(); - + .collect::, _>>()?; versions.sort(); - Ok(versions) + + Ok(versions.iter().map(|version| version.to_string()).collect()) } None => Ok(vec![]), }