make storage users mount id configurable (#5091)

This commit is contained in:
Michael Barz
2022-11-25 13:47:41 +01:00
committed by GitHub
parent 86a108ac49
commit 7e6b57e138
8 changed files with 53 additions and 9 deletions
+4 -3
View File
@@ -80,9 +80,10 @@ type GRPCConfig struct {
}
type StorageRegistry struct {
Driver string `yaml:"driver"` //TODO: configure via env?
Rules []string `yaml:"rules"` //TODO: configure via env?
JSON string `yaml:"json"` //TODO: configure via env?
Driver string `yaml:"driver"` //TODO: configure via env?
Rules []string `yaml:"rules"` //TODO: configure via env?
JSON string `yaml:"json"` //TODO: configure via env?
StorageUsersMountID string `yaml:"storage_users_mount_id" env:"GATEWAY_STORAGE_USERS_MOUNT_ID" desc:"Mount ID of this storage. This ID needs to be unique."`
}
// Cache holds cache config
+11 -2
View File
@@ -2,13 +2,14 @@ package parser
import (
"errors"
"fmt"
ociscfg "github.com/owncloud/ocis/v2/ocis-pkg/config"
defaults2 "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/services/gateway/pkg/config"
"github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
)
// ParseConfig loads configuration from known paths.
@@ -42,5 +43,13 @@ func Validate(cfg *config.Config) error {
return shared.MissingRevaTransferSecretError(cfg.Service.Name)
}
if cfg.StorageRegistry.StorageUsersMountID == "" {
return fmt.Errorf("The storage users mount ID has not been configured for %s. "+
"Make sure your %s config contains the proper values "+
"(e.g. by running ocis init or setting it manually in "+
"the config/corresponding environment variable).",
"gateway", defaults2.BaseConfigPath())
}
return nil
}
+1 -2
View File
@@ -123,11 +123,10 @@ func spacesProviders(cfg *config.Config, logger log.Logger) map[string]map[strin
}
return rules
}
// generate rules based on default config
return map[string]map[string]interface{}{
cfg.StorageUsersEndpoint: {
"providerid": "1284d238-aa92-42ce-bdc4-0b0000009157",
"providerid": cfg.StorageRegistry.StorageUsersMountID,
"spaces": map[string]interface{}{
"personal": map[string]interface{}{
"mount_point": "/users",