add spaces registry, drop mount_path

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
This commit is contained in:
Jörn Friedrich Dreyer
2021-11-09 10:06:08 +00:00
parent 0571467cf6
commit 5a29959a0b
5 changed files with 44 additions and 7 deletions

View File

@@ -181,7 +181,11 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg
"drivers": map[string]interface{}{
"static": map[string]interface{}{
"home_provider": cfg.Reva.StorageRegistry.HomeProvider,
"rules": rules(cfg, logger),
"rules": simpleRules(cfg, logger),
},
"spaces": map[string]interface{}{
"home_provider": cfg.Reva.StorageRegistry.HomeProvider,
"rules": spacesRules(cfg, logger),
},
},
},
@@ -191,7 +195,7 @@ func gatewayConfigFromStruct(c *cli.Context, cfg *config.Config, logger log.Logg
return rcfg
}
func rules(cfg *config.Config, logger log.Logger) map[string]map[string]interface{} {
func simpleRules(cfg *config.Config, logger log.Logger) map[string]map[string]interface{} {
// if a list of rules is given it overrides the generated rules from below
if len(cfg.Reva.StorageRegistry.Rules) > 0 {
@@ -233,6 +237,44 @@ func rules(cfg *config.Config, logger log.Logger) map[string]map[string]interfac
return ret
}
func spacesRules(cfg *config.Config, logger log.Logger) map[string]map[string]interface{} {
// if a list of rules is given it overrides the generated rules from below
if len(cfg.Reva.StorageRegistry.Rules) > 0 {
rules := map[string]map[string]interface{}{}
for i := range cfg.Reva.StorageRegistry.Rules {
parts := strings.SplitN(cfg.Reva.StorageRegistry.Rules[i], "=", 2)
rules[parts[0]] = map[string]interface{}{"address": parts[1]}
}
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 {
logger.Error().Err(err).Msg("Failed to read storage registry rules from JSON file: " + cfg.Reva.StorageRegistry.JSON)
return nil
}
var rules map[string]map[string]interface{}
if err = json.Unmarshal(data, &rules); err != nil {
logger.Error().Err(err).Msg("Failed to unmarshal storage registry rules")
return nil
}
return rules
}
// generate rules based on default config
return map[string]map[string]interface{}{
"/personal": {"address": cfg.Reva.StorageUsers.Endpoint},
// public link storage returns the mount id of the actual storage
"/public": {"address": cfg.Reva.StoragePublicLink.Endpoint},
// TODO shares
//"/shares": {"address": cfg.Reva.StoragePublicLink.Endpoint},
// medatada storage not part of the global namespace
}
}
func mimetypes(cfg *config.Config, logger log.Logger) []map[string]interface{} {
type mimeTypeConfig struct {

View File

@@ -106,7 +106,6 @@ func storageHomeConfigFromStruct(c *cli.Context, cfg *config.Config) map[string]
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageHome.Driver,
"drivers": storagedrivers.HomeDrivers(cfg),
"mount_path": cfg.Reva.StorageHome.MountPath,
"mount_id": cfg.Reva.StorageHome.MountID,
"expose_data_server": cfg.Reva.StorageHome.ExposeDataServer,
"data_server_url": cfg.Reva.StorageHome.DataServerURL,

View File

@@ -132,7 +132,6 @@ func storageMetadataFromStruct(c *cli.Context, cfg *config.Config) map[string]in
},
"services": map[string]interface{}{
"storageprovider": map[string]interface{}{
"mount_path": "/meta",
"driver": cfg.Reva.StorageMetadata.Driver,
"drivers": storagedrivers.MetadataDrivers(cfg),
"data_server_url": cfg.Reva.StorageMetadata.DataServerURL,

View File

@@ -101,8 +101,6 @@ func storagePublicLinkConfigFromStruct(c *cli.Context, cfg *config.Config) map[s
},
"services": map[string]interface{}{
"publicstorageprovider": map[string]interface{}{
"mount_path": cfg.Reva.StoragePublicLink.MountPath,
"mount_id": cfg.Reva.StoragePublicLink.MountID,
"gateway_addr": cfg.Reva.Gateway.Endpoint,
},
"authprovider": map[string]interface{}{

View File

@@ -106,7 +106,6 @@ func storageUsersConfigFromStruct(c *cli.Context, cfg *config.Config) map[string
"storageprovider": map[string]interface{}{
"driver": cfg.Reva.StorageUsers.Driver,
"drivers": storagedrivers.UserDrivers(cfg),
"mount_path": cfg.Reva.StorageUsers.MountPath,
"mount_id": cfg.Reva.StorageUsers.MountID,
"expose_data_server": cfg.Reva.StorageUsers.ExposeDataServer,
"data_server_url": cfg.Reva.StorageUsers.DataServerURL,