From d2fb46f5d398b37d28c82f9732eed73c3fce2d14 Mon Sep 17 00:00:00 2001 From: itowlson Date: Mon, 16 Dec 2024 13:49:16 +1300 Subject: [PATCH 1/4] `spin plugins list --json` Signed-off-by: itowlson --- src/commands/plugins.rs | 65 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/src/commands/plugins.rs b/src/commands/plugins.rs index 639fbacb71..4655c360aa 100644 --- a/src/commands/plugins.rs +++ b/src/commands/plugins.rs @@ -2,7 +2,7 @@ #![allow(clippy::almost_swapped)] use anyhow::{anyhow, Context, Result}; -use clap::{Parser, Subcommand}; +use clap::{Parser, Subcommand, ValueEnum}; use semver::Version; use spin_plugins::{ error::Error, @@ -616,6 +616,16 @@ pub struct List { /// Filter the list to plugins containing this string. #[clap(long = "filter")] pub filter: Option, + + /// The format in which to list the templates. + #[clap(value_enum, long = "format", default_value = "plain")] + pub format: ListFormat, +} + +#[derive(ValueEnum, Clone, Debug)] +pub enum ListFormat { + Plain, + Json, } impl List { @@ -636,11 +646,13 @@ impl List { plugins.retain(|p| p.name.contains(filter)); } - Self::print(&plugins); - Ok(()) + match self.format { + ListFormat::Plain => Self::print_plain(&plugins), + ListFormat::Json => Self::print_json(&plugins), + } } - fn print(plugins: &[PluginDescriptor]) { + fn print_plain(plugins: &[PluginDescriptor]) -> anyhow::Result<()> { if plugins.is_empty() { println!("No plugins found"); } else { @@ -662,6 +674,16 @@ impl List { println!("{} {}{}{}", p.name, p.version, installed, compat); } } + + Ok(()) + } + + fn print_json(plugins: &[PluginDescriptor]) -> anyhow::Result<()> { + let json_vals: Vec<_> = plugins.iter().map(json_list_format).collect(); + + let json_text = serde_json::to_string_pretty(&json_vals)?; + println!("{}", json_text); + Ok(()) } } @@ -670,6 +692,10 @@ impl List { pub struct Search { /// The text to search for. If omitted, all plugins are returned. pub filter: Option, + + /// The format in which to list the plugins. + #[clap(value_enum, long = "format", default_value = "plain")] + pub format: ListFormat, } impl Search { @@ -679,6 +705,7 @@ impl Search { all: true, summary: false, filter: self.filter.clone(), + format: self.format.clone(), }; list_cmd.run().await @@ -731,6 +758,36 @@ impl PluginDescriptor { } } +#[derive(serde::Serialize)] +#[serde(rename_all = "camelCase")] +struct PluginJsonFormat { + name: String, + installed: bool, + version: String, + #[serde(skip_serializing_if = "Option::is_none")] + installed_version: Option, +} + +fn json_list_format(plugin: &PluginDescriptor) -> PluginJsonFormat { + let installed_version = if plugin.installed { + Some( + plugin + .installed_version + .clone() + .unwrap_or_else(|| plugin.version.clone()), + ) + } else { + None + }; + + PluginJsonFormat { + name: plugin.name.clone(), + installed: plugin.installed, + version: plugin.version.clone(), + installed_version, + } +} + // Auxiliar function for Upgrade::upgrade_multiselect fn elements_at(source: Vec, indexes: Vec) -> Vec { source From 8fa1a675a587893cff5e1371f4f49b3112870602 Mon Sep 17 00:00:00 2001 From: itowlson Date: Tue, 17 Dec 2024 09:14:31 +1300 Subject: [PATCH 2/4] Work around breaking change in `cross` Signed-off-by: itowlson --- .github/actions/spin-ci-dependencies/action.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/actions/spin-ci-dependencies/action.yml b/.github/actions/spin-ci-dependencies/action.yml index 844f266b10..b8a4bfee51 100644 --- a/.github/actions/spin-ci-dependencies/action.yml +++ b/.github/actions/spin-ci-dependencies/action.yml @@ -8,7 +8,7 @@ inputs: type: bool rust-version: description: 'Rust version to setup' - default: '1.79' + default: '1.81' required: false type: string diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 141bda9643..022fbfd31b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ concurrency: env: CARGO_TERM_COLOR: always - RUST_VERSION: 1.79 + RUST_VERSION: 1.81 jobs: dependency-review: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c78d47fa95..5d9ee73810 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ on: concurrency: ${{ github.workflow }}-${{ github.ref }} env: - RUST_VERSION: 1.79 + RUST_VERSION: 1.81 jobs: build-and-sign: diff --git a/Cargo.toml b/Cargo.toml index faee0c509b..a9bd7b5025 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" license = "Apache-2.0 WITH LLVM-exception" homepage = "https://developer.fermyon.com/spin" repository = "https://github.com/fermyon/spin" -rust-version = "1.79" +rust-version = "1.81" [dependencies] anyhow = { workspace = true } From 491bc730f3a4804a0442fe3763ec102a00e86c72 Mon Sep 17 00:00:00 2001 From: itowlson Date: Tue, 17 Dec 2024 09:45:23 +1300 Subject: [PATCH 3/4] For now, allow the ! fallback lint Signed-off-by: itowlson --- tests/integration.rs | 1 + tests/testcases/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/integration.rs b/tests/integration.rs index 4b14a1e8a9..442ee3a8d9 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -98,6 +98,7 @@ mod integration_tests { #[test] #[cfg(feature = "extern-dependencies-tests")] + #[allow(dependency_on_unit_never_type_fallback)] /// Test that basic redis trigger support works fn redis_smoke_test() -> anyhow::Result<()> { use anyhow::Context; diff --git a/tests/testcases/mod.rs b/tests/testcases/mod.rs index 358518b510..a6f5ad6c90 100644 --- a/tests/testcases/mod.rs +++ b/tests/testcases/mod.rs @@ -204,6 +204,7 @@ pub fn http_smoke_test_template_with_route( /// Run a smoke test for a `spin new` redis template #[cfg(feature = "extern-dependencies-tests")] +#[allow(dependency_on_unit_never_type_fallback)] pub fn redis_smoke_test_template( template_name: &str, template_url: Option<&str>, From 5bbdefee4534824b8e6e920f7ca0ed3e0b8b76b5 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Mon, 16 Dec 2024 11:26:22 -0800 Subject: [PATCH 4/4] Fix: disable unwinding for musl builds Signed-off-by: Kate Goldenring --- crates/core/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rs index 167fe23c7a..351a973f3f 100644 --- a/crates/core/src/lib.rs +++ b/crates/core/src/lib.rs @@ -77,6 +77,11 @@ impl Default for Config { inner.async_support(true); inner.epoch_interruption(true); inner.wasm_component_model(true); + // If targeting musl, disable native unwind to address this issue: + // https://github.com/fermyon/spin/issues/2889 + // TODO: remove this when wasmtime is updated to >= v27.0.0 + #[cfg(all(target_os = "linux", target_env = "musl"))] + inner.native_unwind_info(false); if use_pooling_allocator_by_default() { // By default enable the pooling instance allocator in Wasmtime. This