From c99e2fc0f26810c1adb7937a2093b17f6099edf4 Mon Sep 17 00:00:00 2001 From: folex <0xdxdy@gmail.com> Date: Wed, 14 Oct 2020 15:08:02 +0300 Subject: [PATCH] Change order of fields in toml configs (#33) --- fluence-faas/src/faas.rs | 5 +++-- fluence-faas/src/raw_toml_config.rs | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/fluence-faas/src/faas.rs b/fluence-faas/src/faas.rs index 2cbe0e13..244f9d63 100644 --- a/fluence-faas/src/faas.rs +++ b/fluence-faas/src/faas.rs @@ -78,11 +78,12 @@ impl FluenceFaaS { let config = config.try_into()?; let call_parameters = Rc::new(RefCell::new(<_>::default())); + let modules_dir = config.modules_dir; for (module_name, module_config) in config.modules_config { let module_bytes = modules.remove(&module_name).ok_or_else(|| { FaaSError::InstantiationError(format!( - "module with name {} is specified in config, but not found in provided modules", - module_name + "module with name {} is specified in config (dir: {:?}), but not found in provided modules: {:?}", + module_name, modules_dir, modules.keys().collect::>() )) })?; diff --git a/fluence-faas/src/raw_toml_config.rs b/fluence-faas/src/raw_toml_config.rs index d5de09b3..2da1bf23 100644 --- a/fluence-faas/src/raw_toml_config.rs +++ b/fluence-faas/src/raw_toml_config.rs @@ -113,8 +113,8 @@ impl TryInto for TomlFaaSNamedModuleConfig { pub struct TomlFaaSModuleConfig { pub mem_pages_count: Option, pub logger_enabled: Option, - pub mounted_binaries: Option, pub wasi: Option, + pub mounted_binaries: Option, } impl TomlFaaSNamedModuleConfig { @@ -131,8 +131,8 @@ impl TomlFaaSNamedModuleConfig { #[derive(Deserialize, Serialize, Debug, Clone, Default)] pub struct TomlWASIConfig { - pub envs: Option, pub preopened_files: Option>, + pub envs: Option, pub mapped_dirs: Option, } @@ -225,3 +225,27 @@ pub fn from_toml_wasi_config(wasi: TomlWASIConfig) -> Result { 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()) + } +}