Add option to read registry rules from json file
This commit is contained in:
@@ -156,8 +156,9 @@ func frontendConfigFromStruct(c *cli.Context, cfg *config.Config, filesCfg map[s
|
||||
"public_url": cfg.Reva.Frontend.PublicURL,
|
||||
},
|
||||
"ocs": map[string]interface{}{
|
||||
"share_prefix": cfg.Reva.Frontend.OCSSharePrefix,
|
||||
"prefix": cfg.Reva.Frontend.OCSPrefix,
|
||||
"share_prefix": cfg.Reva.Frontend.OCSSharePrefix,
|
||||
"home_namespace": cfg.Reva.Frontend.OCSHomeNamespace,
|
||||
"prefix": cfg.Reva.Frontend.OCSPrefix,
|
||||
"config": map[string]interface{}{
|
||||
"version": "1.8",
|
||||
"website": "reva",
|
||||
|
||||
@@ -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