mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 14:55:32 +00:00
Change order of fields in toml configs (#33)
This commit is contained in:
parent
1c2578ede4
commit
c99e2fc0f2
@ -78,11 +78,12 @@ impl FluenceFaaS {
|
|||||||
let config = config.try_into()?;
|
let config = config.try_into()?;
|
||||||
let call_parameters = Rc::new(RefCell::new(<_>::default()));
|
let call_parameters = Rc::new(RefCell::new(<_>::default()));
|
||||||
|
|
||||||
|
let modules_dir = config.modules_dir;
|
||||||
for (module_name, module_config) in config.modules_config {
|
for (module_name, module_config) in config.modules_config {
|
||||||
let module_bytes = modules.remove(&module_name).ok_or_else(|| {
|
let module_bytes = modules.remove(&module_name).ok_or_else(|| {
|
||||||
FaaSError::InstantiationError(format!(
|
FaaSError::InstantiationError(format!(
|
||||||
"module with name {} is specified in config, but not found in provided modules",
|
"module with name {} is specified in config (dir: {:?}), but not found in provided modules: {:?}",
|
||||||
module_name
|
module_name, modules_dir, modules.keys().collect::<Vec<_>>()
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -113,8 +113,8 @@ impl TryInto<FaaSModuleConfig> for TomlFaaSNamedModuleConfig {
|
|||||||
pub struct TomlFaaSModuleConfig {
|
pub struct TomlFaaSModuleConfig {
|
||||||
pub mem_pages_count: Option<u32>,
|
pub mem_pages_count: Option<u32>,
|
||||||
pub logger_enabled: Option<bool>,
|
pub logger_enabled: Option<bool>,
|
||||||
pub mounted_binaries: Option<toml::value::Table>,
|
|
||||||
pub wasi: Option<TomlWASIConfig>,
|
pub wasi: Option<TomlWASIConfig>,
|
||||||
|
pub mounted_binaries: Option<toml::value::Table>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TomlFaaSNamedModuleConfig {
|
impl TomlFaaSNamedModuleConfig {
|
||||||
@ -131,8 +131,8 @@ impl TomlFaaSNamedModuleConfig {
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
|
#[derive(Deserialize, Serialize, Debug, Clone, Default)]
|
||||||
pub struct TomlWASIConfig {
|
pub struct TomlWASIConfig {
|
||||||
pub envs: Option<toml::value::Table>,
|
|
||||||
pub preopened_files: Option<Vec<String>>,
|
pub preopened_files: Option<Vec<String>>,
|
||||||
|
pub envs: Option<toml::value::Table>,
|
||||||
pub mapped_dirs: Option<toml::value::Table>,
|
pub mapped_dirs: Option<toml::value::Table>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,3 +225,27 @@ pub fn from_toml_wasi_config(wasi: TomlWASIConfig) -> Result<FaaSWASIConfig> {
|
|||||||
mapped_dirs,
|
mapped_dirs,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use crate::{TomlFaaSNamedModuleConfig, TomlFaaSModuleConfig, TomlWASIConfig};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn serialize_named() {
|
||||||
|
let config = TomlFaaSNamedModuleConfig {
|
||||||
|
name: "name".to_string(),
|
||||||
|
config: TomlFaaSModuleConfig {
|
||||||
|
mem_pages_count: Some(100),
|
||||||
|
logger_enabled: Some(false),
|
||||||
|
wasi: Some(TomlWASIConfig {
|
||||||
|
preopened_files: Some(vec!["a".to_string()]),
|
||||||
|
envs: None,
|
||||||
|
mapped_dirs: None,
|
||||||
|
}),
|
||||||
|
mounted_binaries: None,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
assert!(toml::to_string(&config).is_ok())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user