Add option to read registry rules from json file

This commit is contained in:
Ishank Arora
2021-04-14 12:57:55 +02:00
parent 4100541baf
commit 8ee5aac82b
6 changed files with 36 additions and 4 deletions
+13
View File
@@ -2,7 +2,9 @@ package command
import (
"context"
"encoding/json"
"flag"
"io/ioutil"
"os"
"path"
"strings"
@@ -184,6 +186,17 @@ func rules(cfg *config.Config) map[string]map[string]interface{} {
return rules
}
// check if the rules have to be read from a json file
if cfg.Reva.StorageRegistry.JSON != "" {
data, err := ioutil.ReadFile(cfg.Reva.StorageRegistry.JSON)
if err != nil {
return nil
}
var rules map[string]map[string]interface{}
_ = json.Unmarshal(data, &rules)
return rules
}
// generate rules based on default config
return map[string]map[string]interface{}{
cfg.Reva.StorageHome.MountPath: {"address": cfg.Reva.StorageHome.Endpoint},