Add option to read registry rules from json file
This commit is contained in:
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user