From c782f646029e79d165c09b3edcf73b7c325dfa0e Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sat, 16 Oct 2021 18:06:45 +0200 Subject: [PATCH] Adapt Forez groups specification for Microservices --- config.yaml | 3 +-- src/data/config.rs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config.yaml b/config.yaml index 75bbd8a..abe37c0 100644 --- a/config.yaml +++ b/config.yaml @@ -81,5 +81,4 @@ admin-url: http://localhost:3001 # This option allows to enable some extra features for these groups # # In most cases you should not have to specify this information -forez_groups: - - 32 \ No newline at end of file +forez_groups: 32 \ No newline at end of file diff --git a/src/data/config.rs b/src/data/config.rs index 8f6835c..eb09144 100644 --- a/src/data/config.rs +++ b/src/data/config.rs @@ -140,6 +140,16 @@ impl Config { }) }; + let forez_groups = match &parsed["forez_groups"] { + Yaml::BadValue => vec![], + _ => { + Self::yaml_str(parsed, "forez_groups") + .split(",") + .map(|f| GroupID::new(f.trim().parse::().unwrap())) + .collect() + } + }; + let conf = Config { port: Config::yaml_u64(parsed, "server-port"), listen_address: Config::yaml_str(parsed, "server-address"), @@ -173,12 +183,7 @@ impl Config { admin_url: Self::yaml_str(parsed, "admin-url"), - forez_groups: parsed["forez_groups"] - .as_vec() - .unwrap_or(&vec![]) - .iter() - .map(|f| GroupID::new(f.as_i64().unwrap() as u64)) - .collect(), + forez_groups, }; // Save new configuration in memory