Change order of fields in toml configs (#33)

This commit is contained in:
folex 2020-10-14 15:08:02 +03:00 committed by GitHub
parent 1c2578ede4
commit c99e2fc0f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -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<_>>()
)) ))
})?; })?;

View File

@ -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())
}
}