mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-04 07:17:16 -05:00
Add option to read registry rules from json file
This commit is contained in:
3
changelog/unreleased/storage-registry-json.md
Normal file
3
changelog/unreleased/storage-registry-json.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Enhancement: Add option to reading registry rules from json file
|
||||
|
||||
https://github.com/owncloud/ocis/pull/1917
|
||||
@@ -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},
|
||||
|
||||
@@ -36,6 +36,7 @@ type StorageRegistry struct {
|
||||
// HomeProvider is the path in the global namespace that the static storage registry uses to determine the home storage
|
||||
HomeProvider string
|
||||
Rules []string
|
||||
JSON string
|
||||
}
|
||||
|
||||
// Sharing defines the available sharing configuration.
|
||||
@@ -109,6 +110,7 @@ type FrontendPort struct {
|
||||
OCDavPrefix string
|
||||
OCSPrefix string
|
||||
OCSSharePrefix string
|
||||
OCSHomeNamespace string
|
||||
PublicURL string
|
||||
Middleware Middleware
|
||||
}
|
||||
|
||||
@@ -119,6 +119,13 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag {
|
||||
EnvVars: []string{"STORAGE_FRONTEND_OCS_SHARE_PREFIX"},
|
||||
Destination: &cfg.Reva.Frontend.OCSSharePrefix,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ocs-home-namespace",
|
||||
Value: flags.OverrideDefaultString(cfg.Reva.Frontend.OCSHomeNamespace, "/home"),
|
||||
Usage: "the prefix prepended to the incoming requests in OCS",
|
||||
EnvVars: []string{"STORAGE_FRONTEND_OCS_HOME_NAMESPACE"},
|
||||
Destination: &cfg.Reva.Frontend.OCSHomeNamespace,
|
||||
},
|
||||
// Gateway
|
||||
|
||||
&cli.StringFlag{
|
||||
|
||||
@@ -140,14 +140,20 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag {
|
||||
Usage: `Replaces the generated storage registry rules with this set: --storage-registry-rule "/eos=localhost:9158" [--storage-registry-rule "1284d238-aa92-42ce-bdc4-0b0000009162=localhost:9162"]`,
|
||||
EnvVars: []string{"STORAGE_STORAGE_REGISTRY_RULES"},
|
||||
},
|
||||
|
||||
&cli.StringFlag{
|
||||
Name: "storage-home-provider",
|
||||
Value: flags.OverrideDefaultString(cfg.Reva.StorageRegistry.HomeProvider, "/home"),
|
||||
Usage: "mount point of the storage provider for user homes in the global namespace",
|
||||
EnvVars: []string{"STORAGE_REGISTRY_HOME_PROVIDER"},
|
||||
EnvVars: []string{"STORAGE_STORAGE_REGISTRY_HOME_PROVIDER"},
|
||||
Destination: &cfg.Reva.StorageRegistry.HomeProvider,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "storage-registry-json",
|
||||
Value: flags.OverrideDefaultString(cfg.Reva.StorageRegistry.JSON, ""),
|
||||
Usage: "JSON file containing the storage registry rules",
|
||||
EnvVars: []string{"STORAGE_STORAGE_REGISTRY_JSON"},
|
||||
Destination: &cfg.Reva.StorageRegistry.JSON,
|
||||
},
|
||||
|
||||
// please note that STORAGE_FRONTEND_PUBLIC_URL is also defined in
|
||||
// storage/pkg/flagset/frontend.go because this setting may be consumed
|
||||
|
||||
Reference in New Issue
Block a user