Skip to content

Commit a4dedd2

Browse files
committed
fix: Sort operator versions by semver version instead of alphabetically
1 parent 20b99d1 commit a4dedd2

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

rust/stackablectl/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file.
1010
[CVE-2024-45311] ([#318]).
1111
- Bump Rust toolchain version to 1.80.1 ([#318]).
1212

13+
### Fixed
14+
15+
- Sort operator versions by semver version instead of alphabetically ([#XXX]).
16+
1317
[#318]: https://github.com/stackabletech/stackable-cockpit/pull/318
1418
[CVE-2024-45311]: https://github.com/advisories/GHSA-vr26-jcq5-fjj8
1519

rust/stackablectl/src/cmds/operator.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ pub enum CmdError {
130130
#[snafu(display("invalid repository name"))]
131131
InvalidRepoName { source: InvalidRepoNameError },
132132

133+
#[snafu(display("invalid helm chart version {version:?}"))]
134+
InvalidHelmChartVersion {
135+
source: semver::Error,
136+
version: String,
137+
},
138+
133139
#[snafu(display("unknown repository name '{name}'"))]
134140
UnknownRepoName { name: String },
135141

@@ -524,16 +530,15 @@ where
524530
Some(entries) => {
525531
let mut versions = entries
526532
.iter()
527-
.map(|e| Version::parse(&e.version))
528-
.map_while(|r| match r {
529-
Ok(v) => Some(v),
530-
Err(_) => None,
533+
.map(|entry| {
534+
Version::parse(&entry.version).context(InvalidHelmChartVersionSnafu {
535+
version: entry.version.clone(),
536+
})
531537
})
532-
.map(|v| v.to_string())
533-
.collect::<Vec<String>>();
534-
538+
.collect::<Result<Vec<_>, _>>()?;
535539
versions.sort();
536-
Ok(versions)
540+
541+
Ok(versions.iter().map(|version| version.to_string()).collect())
537542
}
538543
None => Ok(vec![]),
539544
}

0 commit comments

Comments
 (0)