Skip to content

Commit 096a32c

Browse files
Merge pull request #2426 from itowlson/im-mad-as-hell-and-im-not-going-take-it-any-more-well-maybe-not-mad-but-grr
Option to suppress plugin on-run compatibility warnings
2 parents 08129a8 + bddecae commit 096a32c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/plugins/src/manifest.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,16 @@ fn inner_warn_unsupported_version(
181181
override_compatibility_check: bool,
182182
) -> Result<()> {
183183
if !is_version_fully_compatible(supported_on, spin_version)? {
184+
let show_warnings = !suppress_compatibility_warnings();
184185
let version = Version::parse(spin_version)?;
185186
if !version.pre.is_empty() {
186-
if std::io::stderr().is_terminal() {
187+
if std::io::stderr().is_terminal() && show_warnings {
187188
terminal::warn!("You're using a pre-release version of Spin ({spin_version}). This plugin might not be compatible (supported: {supported_on}). Continuing anyway.");
188189
}
189190
} else if override_compatibility_check {
190-
terminal::warn!("Plugin is not compatible with this version of Spin (supported: {supported_on}, actual: {spin_version}). Check overridden ... continuing to install or execute plugin.");
191+
if show_warnings {
192+
terminal::warn!("Plugin is not compatible with this version of Spin (supported: {supported_on}, actual: {spin_version}). Check overridden ... continuing to install or execute plugin.");
193+
}
191194
} else {
192195
return Err(anyhow!(
193196
"Plugin is not compatible with this version of Spin (supported: {supported_on}, actual: {spin_version}). Try running `spin plugins update && spin plugins upgrade --all` to install latest or override with `--override-compatibility-check`."
@@ -197,6 +200,13 @@ fn inner_warn_unsupported_version(
197200
Ok(())
198201
}
199202

203+
fn suppress_compatibility_warnings() -> bool {
204+
match std::env::var("SPIN_PLUGINS_SUPPRESS_COMPATIBILITY_WARNINGS") {
205+
Ok(s) => !s.is_empty(),
206+
Err(_) => false,
207+
}
208+
}
209+
200210
#[cfg(test)]
201211
mod test {
202212
use super::*;

0 commit comments

Comments
 (0)