From 068a8c98d6c81b1c37bfe7f66205da67c92299de Mon Sep 17 00:00:00 2001 From: Fang Date: Sun, 1 Mar 2020 01:31:05 +0100 Subject: [PATCH] metadata: add helper lib for common queries --- pkg/arvo/lib/metadata.hoon | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 pkg/arvo/lib/metadata.hoon diff --git a/pkg/arvo/lib/metadata.hoon b/pkg/arvo/lib/metadata.hoon new file mode 100644 index 000000000..b83909674 --- /dev/null +++ b/pkg/arvo/lib/metadata.hoon @@ -0,0 +1,54 @@ +:: metadata: helpers for getting data from the metadata-store +:: +/- *metadata-store +:: +|_ =bowl:gall +++ app-paths-from-group + |= [=app-name =group-path] + ^- (list app-path) + %+ murn + %~ tap in + =- (~(gut by -) group-path ~) + .^ (jug ^group-path resource) + %gy + (scot %p our.bowl) + %metadata-store + (scot %da now.bowl) + /group-indices + == + |= =resource + ^- (unit app-path) + ?. =(app-name.resource app-name) ~ + `app-path.resource +:: +++ groups-from-resource + |= =resource + ^- (list group-path) + =; resources + %~ tap in + %+ ~(gut by resources) + resource + *(set group-path) + .^ (jug ^resource group-path) + %gy + (scot %p our.bowl) + %metadata-store + (scot %da now.bowl) + /resource-indices + == +:: +++ check-resource-permissions + |= [=ship =resource] + ^- ? + %+ lien (groups-from-resource resource) + |= =group-path + .^ ? + %gx + (scot %p our.bowl) + %permission-store + (scot %da now.bowl) + %permitted + (scot %p ship) + (snoc group-path %noun) + == +-- \ No newline at end of file