Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/spin-ci-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
type: bool
rust-version:
description: 'Rust version to setup'
default: '1.79'
default: '1.81'
required: false
type: string

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ concurrency:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.79
RUST_VERSION: 1.81

jobs:
dependency-review:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
RUST_VERSION: 1.79
RUST_VERSION: 1.81

jobs:
build-and-sign:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 61 additions & 4 deletions src/commands/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -616,6 +616,16 @@ pub struct List {
/// Filter the list to plugins containing this string.
#[clap(long = "filter")]
pub filter: Option<String>,

/// 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 {
Expand All @@ -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 {
Expand All @@ -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(())
}
}

Expand All @@ -670,6 +692,10 @@ impl List {
pub struct Search {
/// The text to search for. If omitted, all plugins are returned.
pub filter: Option<String>,

/// The format in which to list the plugins.
#[clap(value_enum, long = "format", default_value = "plain")]
pub format: ListFormat,
}

impl Search {
Expand All @@ -679,6 +705,7 @@ impl Search {
all: true,
summary: false,
filter: self.filter.clone(),
format: self.format.clone(),
};

list_cmd.run().await
Expand Down Expand Up @@ -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<String>,
}

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<T>(source: Vec<T>, indexes: Vec<usize>) -> Vec<T> {
source
Expand Down
1 change: 1 addition & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/testcases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down