Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes (attempt 2/3)
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored and jdx committed Dec 16, 2024
1 parent f472cee commit 051f7a1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
44 changes: 22 additions & 22 deletions schema/mise.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,28 +294,6 @@
"description": "Enable experimental mise features which are incomplete or unstable—breakings changes may occur",
"type": "boolean"
},
"sops": {
"additionalProperties": false,
"properties": {
"rops": {
"default": true,
"description": "Use rops to decrypt sops files. Disable to shell out to `sops` which will slow down mise but sops may offer features not available in rops.",
"type": "boolean"
},
"age_key": {
"description": "The age private key to use for sops secret decryption.",
"type": "string"
},
"age_key_file": {
"description": "Path to the age private key file to use for sops secret decryption.",
"type": "string"
},
"age_recipients": {
"description": "The age public keys to use for sops secret encryption.",
"type": "string"
}
}
},
"fetch_remote_versions_cache": {
"default": "1h",
"description": "How long to cache remote versions for tools.",
Expand Down Expand Up @@ -680,6 +658,28 @@
"description": "Suppress all `mise run|watch` output except errors—including what tasks output.",
"type": "boolean"
},
"sops": {
"additionalProperties": false,
"properties": {
"age_key": {
"description": "The age private key to use for sops secret decryption.",
"type": "string"
},
"age_key_file": {
"description": "Path to the age private key file to use for sops secret decryption.",
"type": "string"
},
"age_recipients": {
"description": "The age public keys to use for sops secret encryption.",
"type": "string"
},
"rops": {
"default": true,
"description": "Use rops to decrypt sops files. Disable to shell out to `sops` which will slow down mise but sops may offer features not available in rops.",
"type": "boolean"
}
}
},
"status": {
"additionalProperties": false,
"properties": {
Expand Down
4 changes: 2 additions & 2 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ impl Config {
.get_or_try_init(|| ToolRequestSetBuilder::new().build())
}

pub fn get_toolset(&self) -> eyre::Result<&Toolset> {
pub fn get_toolset(&self) -> Result<&Toolset> {
self.toolset.get_or_try_init(|| {
let mut ts = Toolset::from(self.get_tool_request_set()?.clone());
ts.resolve()?;
Ok(ts)
})
}

pub fn get_repo_url(&self, plugin_name: &str) -> Option<String> {
let plugin_name = self
.all_aliases
Expand Down
15 changes: 10 additions & 5 deletions src/sops.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::config::SETTINGS;
use crate::config::{Config, SETTINGS};
use crate::file::replace_path;
use crate::{dirs, file, result};
use eyre::WrapErr;
Expand Down Expand Up @@ -66,19 +66,24 @@ where
.wrap_err("failed to decrypt sops file")?
.to_string()
} else {
// TODO: this won't work right if sops is coming from mise since tools won't have been loaded
let config = Config::get();
let mut ts = config.get_tool_request_set().cloned().unwrap_or_default()
.filter_by_tool(["sops".into()].into())
.into_toolset();
ts.resolve()?;
let sops = ts.which_bin("sops").map(|s| s.to_string_lossy().to_string()).unwrap_or("sops".into());
// TODO: this obviously won't work on windows
cmd!(
"sops",
sops,
"--input-type",
format,
"--output-type",
format,
"-d",
"/dev/stdin"
)
.stdin_bytes(input.as_bytes())
.read()?
.stdin_bytes(input.as_bytes())
.read()?
};

if let Some(age) = prev_age {
Expand Down
10 changes: 6 additions & 4 deletions src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,10 +539,12 @@ impl Toolset {
self.list_current_installed_versions()
.into_par_iter()
.find_first(|(p, tv)| {
if let Ok(x) = p.which(tv, bin_name) {
x.is_some()
} else {
false
match p.which(tv, bin_name) {
Ok(x) => x.is_some(),
Err(e) => {
debug!("Error running which: {:#}", e);
false
}
}
})
}
Expand Down
6 changes: 5 additions & 1 deletion src/toolset/tool_request_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::cli::args::{BackendArg, ToolArg};
use crate::config::{Config, Settings};
use crate::env;
use crate::registry::REGISTRY;
use crate::toolset::{ToolRequest, ToolSource};
use crate::toolset::{ToolRequest, ToolSource, Toolset};

#[derive(Debug, Default, Clone)]
pub struct ToolRequestSet {
Expand Down Expand Up @@ -86,6 +86,10 @@ impl ToolRequestSet {
.map(|(fa, trl, ts)| (fa.clone(), trl.clone(), ts.clone()))
.collect::<ToolRequestSet>()
}

pub fn into_toolset(self) -> Toolset {
self.into()
}
}

impl Display for ToolRequestSet {
Expand Down

0 comments on commit 051f7a1

Please sign in to comment.