feat: Add the ability to set args for module calls

This commit is contained in:
Gerald Pinder 2025-05-17 18:09:08 -04:00
parent 2b75e2a6ef
commit abd19b6f72
3 changed files with 37 additions and 0 deletions

View file

@ -31,6 +31,10 @@ pub struct ModuleRequiredFields<'a> {
#[serde(rename = "no-cache", default, skip_serializing_if = "is_false")]
pub no_cache: bool,
#[builder(into)]
#[serde(skip_serializing_if = "Option::is_none")]
pub env: Option<IndexMap<String, String>>,
#[serde(flatten)]
#[builder(default, into)]
pub config: IndexMap<String, Value>,
@ -77,6 +81,15 @@ impl<'a> ModuleRequiredFields<'a> {
))
}
#[must_use]
pub fn get_env(&self) -> Vec<(&String, &String)> {
self.env
.as_ref()
.iter()
.flat_map(|args| args.iter())
.collect()
}
#[must_use]
pub fn get_non_local_source(&'a self) -> Option<&'a str> {
let source = self.source.as_deref()?;