From a4dedd2cb3ba854f822009296b2b3c01e1ea45da Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 18 Nov 2024 16:16:43 +0100 Subject: [PATCH 01/11] fix: Sort operator versions by semver version instead of alphabetically --- rust/stackablectl/CHANGELOG.md | 4 ++++ rust/stackablectl/src/cmds/operator.rs | 21 +++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) 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![]), } From 5da958e1f03ff9116d2a21f8636226aa312301ba Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 18 Nov 2024 16:18:46 +0100 Subject: [PATCH 02/11] changelog --- rust/stackablectl/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 430f1344..c1b760f4 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -12,9 +12,10 @@ All notable changes to this project will be documented in this file. ### Fixed -- Sort operator versions by semver version instead of alphabetically ([#XXX]). +- Sort operator versions by semver version instead of alphabetically ([#336]). [#318]: https://github.com/stackabletech/stackable-cockpit/pull/318 +[#336]: https://github.com/stackabletech/stackable-cockpit/pull/336 [CVE-2024-45311]: https://github.com/advisories/GHSA-vr26-jcq5-fjj8 ## [24.7.1] - 2024-08-15 From 1ff556cede76f0f0916aa955e72a7b0daf1810e9 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 18 Nov 2024 16:19:49 +0100 Subject: [PATCH 03/11] Improve error message --- rust/stackablectl/src/cmds/operator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 7328d03d..97d87499 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -130,7 +130,7 @@ pub enum CmdError { #[snafu(display("invalid repository name"))] InvalidRepoName { source: InvalidRepoNameError }, - #[snafu(display("invalid helm chart version {version:?}"))] + #[snafu(display("invalid helm chart version {version:?} (need to be semver)"))] InvalidHelmChartVersion { source: semver::Error, version: String, From d091fbcac8a81f8338623aac8e3c7d68aece1ffd Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:11:10 +0100 Subject: [PATCH 04/11] Fix pre-commit stuff --- .pre-commit-config.yaml | 2 +- README.md | 3 +-- crate-hashes.json | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5294b678..03328ac8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: - id: fmt args: ["--all", "--", "--check"] - id: clippy - args: ["--all-targets", "--", "-D", "warnings"] + args: ["--all-targets", "--all-features", "--", "-D", "warnings"] - repo: https://github.com/adrienverge/yamllint rev: 81e9f98ffd059efe8aa9c1b1a42e5cce61b640c6 # 1.35.1 diff --git a/README.md b/README.md index 2e0c3c35..688e4083 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ hooks are: - [`yamllint`](https://github.com/adrienverge/yamllint): Runs linting on all YAML files - [`markdownlint`](https://github.com/igorshubovych/markdownlint-cli): Runs linting on all Markdown files - [`prettier`](https://github.com/pre-commit/mirrors-prettier): Runs prettier on files located in `web` -- `cargo clippy -- -D warnings`: Runs Clippy on all files and errors on warnings +- `cargo clippy --all-targets --all-features -- -D warnings`: Runs Clippy on all files and errors on warnings - `cargo fmt -- --check`: Checks if Rust code needs formatting - `cargo xtask gen-comp`: Runs shell completions generation for `stackablectl` - `cargo xtask gen-man`: Runs man page generation for `stackablectl` @@ -77,4 +77,3 @@ hooks are: [pre-commit]: https://pre-commit.com/ [web-readme]: ./web/README.md [lib-readme]: ./rust/stackable-cockpit/README.md -[xtasks]: ./xtask/src/main.rs diff --git a/crate-hashes.json b/crate-hashes.json index 8725a492..d6326daf 100644 --- a/crate-hashes.json +++ b/crate-hashes.json @@ -2,4 +2,4 @@ "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.74.0#stackable-operator-derive@0.3.1": "1g1a0v98wlcb36ibwv1nv75g3b3s1mjmaps443fc2w2maam94lya", "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.74.0#stackable-operator@0.74.0": "1g1a0v98wlcb36ibwv1nv75g3b3s1mjmaps443fc2w2maam94lya", "git+https://github.com/stackabletech/product-config.git?tag=0.7.0#product-config@0.7.0": "0gjsm80g6r75pm3824dcyiz4ysq1ka4c1if6k1mjm9cnd5ym0gny" -} \ No newline at end of file +} From 8be6b9e6097f4bbe1ab483ab7230822d328a7676 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:18:32 +0100 Subject: [PATCH 05/11] Add node to pre-commit CI action --- .github/workflows/pr_pre-commit.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr_pre-commit.yml b/.github/workflows/pr_pre-commit.yml index 8a530e2d..3e280065 100644 --- a/.github/workflows/pr_pre-commit.yml +++ b/.github/workflows/pr_pre-commit.yml @@ -19,6 +19,11 @@ jobs: - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 with: python-version: '3.12' + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: 18 + cache: yarn + - run: yarn install --frozen-lockfile - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }} From 226cb3ca509b4647f521893e8d5f9a11567d4a99 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:30:01 +0100 Subject: [PATCH 06/11] Improve error reporting in web/build.rs --- web/build.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/web/build.rs b/web/build.rs index e7a47b88..eecda6d7 100644 --- a/web/build.rs +++ b/web/build.rs @@ -16,18 +16,21 @@ fn main() { ] { println!("cargo:rerun-if-changed={tracked_file}"); } - let vite_status = Command::new("yarn") + + let mut vite_command = Command::new("yarn"); + vite_command .arg("run") .arg("build") .arg("--outDir") .arg(&vite_out_dir) .arg("--base") - .arg("/ui/") - .status() - .unwrap(); - if !vite_status.success() { - panic!("web-ui build failed: {vite_status}"); - } + .arg("/ui/"); + let vite_status = vite_command.status(); + match vite_status { + Ok(vite_status) if vite_status.success() => {} + _ => panic!("web-ui build failed: command {vite_command:?} resulted in {vite_status:?}"), + }; + let mut asset_map = phf_codegen::Map::new(); for asset_file in vite_out_dir.join("assets").read_dir().unwrap() { let asset_file = asset_file.unwrap(); From bf1c26c15dc9624f942dc290807381ee6cb07d0a Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:30:54 +0100 Subject: [PATCH 07/11] Install node thingies in pre-commit action --- .github/workflows/pr_pre-commit.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/pr_pre-commit.yml b/.github/workflows/pr_pre-commit.yml index fca98d91..d107e683 100644 --- a/.github/workflows/pr_pre-commit.yml +++ b/.github/workflows/pr_pre-commit.yml @@ -19,6 +19,11 @@ jobs: - uses: cachix/install-nix-action@08dcb3a5e62fa31e2da3d490afc4176ef55ecd72 #v30 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version: 18 + cache: yarn + - run: yarn install --frozen-lockfile - uses: stackabletech/actions/run-pre-commit@9bd13255f286e4b7a654617268abe1b2f37c3e0a # v0.3.0 with: rust: ${{ env.RUST_TOOLCHAIN_VERSION }} From f4dc0b28e2b0b6a1066186659a57e01df8a61085 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:40:13 +0100 Subject: [PATCH 08/11] changelog --- rust/stackablectl/CHANGELOG.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index c59d36da..75c80e66 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed + +- Sort operator versions by semver version instead of alphabetically ([#336]). + +[#336]: https://github.com/stackabletech/stackable-cockpit/pull/336 + ## [24.11.0] - 2024-11-18 ### Changed @@ -12,12 +18,8 @@ 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 ([#336]). [#318]: https://github.com/stackabletech/stackable-cockpit/pull/318 -[#336]: https://github.com/stackabletech/stackable-cockpit/pull/336 [CVE-2024-45311]: https://github.com/advisories/GHSA-vr26-jcq5-fjj8 ## [24.7.1] - 2024-08-15 From d3443fdca360d14b3807fd6b056c57259ff06ea2 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Tue, 19 Nov 2024 08:43:55 +0100 Subject: [PATCH 09/11] changelog --- rust/stackablectl/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 75c80e66..b876fcde 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -18,7 +18,6 @@ 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]). - [#318]: https://github.com/stackabletech/stackable-cockpit/pull/318 [CVE-2024-45311]: https://github.com/advisories/GHSA-vr26-jcq5-fjj8 From 52078f080d7c60ecc5c71e1660eac29e11b3d6bf Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Nov 2024 13:13:28 +0100 Subject: [PATCH 10/11] Apply suggestions from code review Co-authored-by: Techassi --- rust/stackablectl/src/cmds/operator.rs | 4 ++-- web/build.rs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 97d87499..e64c6deb 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -130,7 +130,7 @@ pub enum CmdError { #[snafu(display("invalid repository name"))] InvalidRepoName { source: InvalidRepoNameError }, - #[snafu(display("invalid helm chart version {version:?} (need to be semver)"))] + #[snafu(display("invalid semantic helm chart version {version:?}"))] InvalidHelmChartVersion { source: semver::Error, version: String, @@ -531,7 +531,7 @@ where let mut versions = entries .iter() .map(|entry| { - Version::parse(&entry.version).context(InvalidHelmChartVersionSnafu { + Version::parse(&entry.version).with_context(|_| InvalidHelmChartVersionSnafu { version: entry.version.clone(), }) }) diff --git a/web/build.rs b/web/build.rs index eecda6d7..3e8de5e0 100644 --- a/web/build.rs +++ b/web/build.rs @@ -25,6 +25,7 @@ fn main() { .arg(&vite_out_dir) .arg("--base") .arg("/ui/"); + let vite_status = vite_command.status(); match vite_status { Ok(vite_status) if vite_status.success() => {} From 2e8c23b4201a216653d567454a87be08e68d0727 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Nov 2024 15:01:48 +0100 Subject: [PATCH 11/11] cargo fmt --- rust/stackablectl/src/cmds/operator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index e64c6deb..7e955b10 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -130,7 +130,7 @@ pub enum CmdError { #[snafu(display("invalid repository name"))] InvalidRepoName { source: InvalidRepoNameError }, - #[snafu(display("invalid semantic helm chart version {version:?}"))] + #[snafu(display("invalid semantic helm chart version {version:?}"))] InvalidHelmChartVersion { source: semver::Error, version: String,