From f524079914f70542b1a494662b44264ef8e608c7 Mon Sep 17 00:00:00 2001 From: Nadja Reitzenstein Date: Wed, 5 Jan 2022 21:15:05 +0100 Subject: [PATCH] Implement categories support --- examples/bffh.dhall | 1 + src/api/machines.rs | 3 +++ src/config.rs | 1 + src/machine.rs | 3 +++ 4 files changed, 8 insertions(+) diff --git a/examples/bffh.dhall b/examples/bffh.dhall index 249f473..a541710 100644 --- a/examples/bffh.dhall +++ b/examples/bffh.dhall @@ -43,6 +43,7 @@ }, Another = { wiki = "test_another" + , category = "test" , disclose = "lab.test.read" , manage = "lab.test.admin" , name = "Another" diff --git a/src/api/machines.rs b/src/api/machines.rs index 878b57d..cc2d5c5 100644 --- a/src/api/machines.rs +++ b/src/api/machines.rs @@ -194,6 +194,9 @@ async fn fill_machine_builder( if let Some(ref wiki) = machine.desc.wiki { builder.set_wiki(wiki); } + if let Some(ref category) = machine.desc.category { + builder.set_category(category); + } builder.set_urn(&format!("urn:fabaccess:resource:{}", id.as_ref())); let machineapi = Machine::new(user.clone(), perms, machine.clone()); diff --git a/src/config.rs b/src/config.rs index 79f1a0c..974fe54 100644 --- a/src/config.rs +++ b/src/config.rs @@ -97,6 +97,7 @@ impl Default for Config { name: "Testmachine".to_string(), description: Some("A test machine".to_string()), wiki: None, + category: None, privs: PrivilegesBuf { disclose: PermissionBuf::from_string("lab.test.read".to_string()), read: PermissionBuf::from_string("lab.test.read".to_string()), diff --git a/src/machine.rs b/src/machine.rs index 9bd53c7..0ff2268 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -368,6 +368,9 @@ pub struct MachineDescription { #[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "deser_option")] pub wiki: Option, + #[serde(default, skip_serializing_if = "Option::is_none", deserialize_with = "deser_option")] + pub category: Option, + /// The permission required #[serde(flatten)] pub privs: access::PrivilegesBuf,