From 8cd39754c7fe733becdf836a6952ba6e70182e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Tue, 23 Apr 2024 08:37:53 +0200 Subject: [PATCH] Add config vars for space path templates --- services/storage-users/pkg/config/config.go | 12 +++++--- .../pkg/config/defaults/defaultconfig.go | 10 +++++-- .../storage-users/pkg/revaconfig/drivers.go | 30 ++++++++++++------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/services/storage-users/pkg/config/config.go b/services/storage-users/pkg/config/config.go index 61ed7c8428..3d369246b0 100644 --- a/services/storage-users/pkg/config/config.go +++ b/services/storage-users/pkg/config/config.go @@ -126,9 +126,11 @@ type OCISDriver struct { // PersonalSpaceAliasTemplate contains the template used to construct // the personal space alias, eg: `"{{.SpaceType}}/{{.User.Username | lower}}"` PersonalSpaceAliasTemplate string `yaml:"personalspacealias_template" env:"STORAGE_USERS_OCIS_PERSONAL_SPACE_ALIAS_TEMPLATE" desc:"Template string to construct personal space aliases." introductionVersion:"pre5.0"` + PersonalSpacePathTemplate string `yaml:"personalspacepath_template" env:"STORAGE_USERS_OCIS_PERSONAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the personal space roots."` // GeneralSpaceAliasTemplate contains the template used to construct // the general space alias, eg: `{{.SpaceType}}/{{.SpaceName | replace " " "-" | lower}}` GeneralSpaceAliasTemplate string `yaml:"generalspacealias_template" env:"STORAGE_USERS_OCIS_GENERAL_SPACE_ALIAS_TEMPLATE" desc:"Template string to construct general space aliases." introductionVersion:"pre5.0"` + GeneralSpacePathTemplate string `yaml:"generalspacepath_template" env:"STORAGE_USERS_OCIS_GENERAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the projects space roots."` // ShareFolder defines the name of the folder jailing all shares ShareFolder string `yaml:"share_folder" env:"STORAGE_USERS_OCIS_SHARE_FOLDER" desc:"Name of the folder jailing all shares." introductionVersion:"pre5.0"` MaxAcquireLockCycles int `yaml:"max_acquire_lock_cycles" env:"STORAGE_USERS_OCIS_MAX_ACQUIRE_LOCK_CYCLES" desc:"When trying to lock files, ocis will try this amount of times to acquire the lock before failing. After each try it will wait for an increasing amount of time. Values of 0 or below will be ignored and the default value will be used." introductionVersion:"pre5.0"` @@ -161,9 +163,11 @@ type S3NGDriver struct { // PersonalSpaceAliasTemplate contains the template used to construct // the personal space alias, eg: `"{{.SpaceType}}/{{.User.Username | lower}}"` PersonalSpaceAliasTemplate string `yaml:"personalspacealias_template" env:"STORAGE_USERS_S3NG_PERSONAL_SPACE_ALIAS_TEMPLATE" desc:"Template string to construct personal space aliases." introductionVersion:"pre5.0"` + PersonalSpacePathTemplate string `yaml:"personalspacepath_template" env:"STORAGE_USERS_S3NG_PERSONAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the personal space roots."` // GeneralSpaceAliasTemplate contains the template used to construct // the general space alias, eg: `{{.SpaceType}}/{{.SpaceName | replace " " "-" | lower}}` GeneralSpaceAliasTemplate string `yaml:"generalspacealias_template" env:"STORAGE_USERS_S3NG_GENERAL_SPACE_ALIAS_TEMPLATE" desc:"Template string to construct general space aliases." introductionVersion:"pre5.0"` + GeneralSpacePathTemplate string `yaml:"generalspacepath_template" env:"STORAGE_USERS_S3NG_GENERAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the projects space roots."` // ShareFolder defines the name of the folder jailing all shares ShareFolder string `yaml:"share_folder" env:"STORAGE_USERS_S3NG_SHARE_FOLDER" desc:"Name of the folder jailing all shares." introductionVersion:"pre5.0"` MaxAcquireLockCycles int `yaml:"max_acquire_lock_cycles" env:"STORAGE_USERS_S3NG_MAX_ACQUIRE_LOCK_CYCLES" desc:"When trying to lock files, ocis will try this amount of times to acquire the lock before failing. After each try it will wait for an increasing amount of time. Values of 0 or below will be ignored and the default value of 20 will be used." introductionVersion:"pre5.0"` @@ -190,10 +194,10 @@ type OwnCloudSQLDriver struct { // PosixDriver is the storage driver configuration when using 'posix' storage driver type PosixDriver struct { // Root is the absolute path to the location of the data - Root string `yaml:"root" env:"STORAGE_USERS_POSIX_ROOT" desc:"The directory where the filesystem storage will store its data. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage/owncloud."` - UserLayout string `yaml:"user_layout" env:"STORAGE_USERS_POSIX_USER_LAYOUT" desc:"Template string for the user storage layout in the user directory."` - ProjectLayout string `yaml:"project_layout" env:"STORAGE_USERS_POSIX_PROJECT_LAYOUT" desc:"Template string for the project spaces storage layout."` - PermissionsEndpoint string `yaml:"permissions_endpoint" env:"STORAGE_USERS_PERMISSION_ENDPOINT;STORAGE_USERS_POSIX_PERMISSIONS_ENDPOINT" desc:"Endpoint of the permissions service. The endpoints can differ for 'ocis', 'posix' and 's3ng'."` + Root string `yaml:"root" env:"STORAGE_USERS_POSIX_ROOT" desc:"The directory where the filesystem storage will store its data. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH:/storage/owncloud."` + PersonalSpacePathTemplate string `yaml:"personalspacepath_template" env:"STORAGE_USERS_POSIX_PERSONAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the personal space roots."` + GeneralSpacePathTemplate string `yaml:"generalspacepath_template" env:"STORAGE_USERS_POSIX_GENERAL_SPACE_PATH_TEMPLATE" desc:"Template string to construct the paths of the projects space roots."` + PermissionsEndpoint string `yaml:"permissions_endpoint" env:"STORAGE_USERS_PERMISSION_ENDPOINT;STORAGE_USERS_POSIX_PERMISSIONS_ENDPOINT" desc:"Endpoint of the permissions service. The endpoints can differ for 'ocis', 'posix' and 's3ng'."` WatchType string `yaml:"watch_type" env:"STORAGE_USERS_POSIX_WATCH_TYPE" desc:"Type of the watcher to use for getting notified about changes to the filesystem. Currently available options are 'inotifywait' (default) and 'gpfsfileauditlogging'."` WatchPath string `yaml:"watch_path" env:"STORAGE_USERS_POSIX_WATCH_PATH" desc:"Path to the watch directory/file. Only applies to the 'gpfsfileauditlogling' watcher, in which case it is the path of the file audit log file."` diff --git a/services/storage-users/pkg/config/defaults/defaultconfig.go b/services/storage-users/pkg/config/defaults/defaultconfig.go index 04017bc618..74a8a818df 100644 --- a/services/storage-users/pkg/config/defaults/defaultconfig.go +++ b/services/storage-users/pkg/config/defaults/defaultconfig.go @@ -116,7 +116,9 @@ func DefaultConfig() *config.Config { ConcurrentStreamParts: true, NumThreads: 4, PersonalSpaceAliasTemplate: "{{.SpaceType}}/{{.User.Username | lower}}", + PersonalSpacePathTemplate: "", GeneralSpaceAliasTemplate: "{{.SpaceType}}/{{.SpaceName | replace \" \" \"-\" | lower}}", + GeneralSpacePathTemplate: "", PermissionsEndpoint: "com.owncloud.api.settings", MaxAcquireLockCycles: 20, MaxConcurrency: 5, @@ -130,7 +132,9 @@ func DefaultConfig() *config.Config { ShareFolder: "/Shares", UserLayout: "{{.Id.OpaqueId}}", PersonalSpaceAliasTemplate: "{{.SpaceType}}/{{.User.Username | lower}}", + PersonalSpacePathTemplate: "", GeneralSpaceAliasTemplate: "{{.SpaceType}}/{{.SpaceName | replace \" \" \"-\" | lower}}", + GeneralSpacePathTemplate: "", PermissionsEndpoint: "com.owncloud.api.settings", MaxAcquireLockCycles: 20, MaxConcurrency: 5, @@ -138,9 +142,9 @@ func DefaultConfig() *config.Config { AsyncUploads: true, }, Posix: config.PosixDriver{ - UserLayout: "users/{{.User.Username}}", - ProjectLayout: "projects/{{.SpaceId}}", - PermissionsEndpoint: "com.owncloud.api.settings", + PersonalSpacePathTemplate: "users/{{.User.Username}}", + GeneralSpacePathTemplate: "projects/{{.SpaceId}}", + PermissionsEndpoint: "com.owncloud.api.settings", }, }, Events: config.Events{ diff --git a/services/storage-users/pkg/revaconfig/drivers.go b/services/storage-users/pkg/revaconfig/drivers.go index 0bfd065200..5c3f2e4f32 100644 --- a/services/storage-users/pkg/revaconfig/drivers.go +++ b/services/storage-users/pkg/revaconfig/drivers.go @@ -87,13 +87,13 @@ func Local(cfg *config.Config) map[string]interface{} { // Posix is the config mapping for the Posix storage driver func Posix(cfg *config.Config) map[string]interface{} { return map[string]interface{}{ - "root": cfg.Drivers.Posix.Root, - "user_layout": cfg.Drivers.Posix.UserLayout, - "project_layout": cfg.Drivers.Posix.ProjectLayout, - "permissionssvc": cfg.Drivers.Posix.PermissionsEndpoint, - "permissionssvc_tls_mode": cfg.Commons.GRPCClientTLS.Mode, - "treetime_accounting": true, - "treesize_accounting": true, + "root": cfg.Drivers.Posix.Root, + "personalspacepath_template": cfg.Drivers.Posix.PersonalSpacePathTemplate, + "generalspacepath_template": cfg.Drivers.Posix.GeneralSpacePathTemplate, + "permissionssvc": cfg.Drivers.Posix.PermissionsEndpoint, + "permissionssvc_tls_mode": cfg.Commons.GRPCClientTLS.Mode, + "treetime_accounting": true, + "treesize_accounting": true, "idcache": map[string]interface{}{ "cache_store": cfg.IDCache.Store, "cache_nodes": cfg.IDCache.Nodes, @@ -149,7 +149,9 @@ func Ocis(cfg *config.Config) map[string]interface{} { "user_layout": cfg.Drivers.OCIS.UserLayout, "share_folder": cfg.Drivers.OCIS.ShareFolder, "personalspacealias_template": cfg.Drivers.OCIS.PersonalSpaceAliasTemplate, + "personalspacepath_template": cfg.Drivers.OCIS.PersonalSpacePathTemplate, "generalspacealias_template": cfg.Drivers.OCIS.GeneralSpaceAliasTemplate, + "generalspacepath_template": cfg.Drivers.OCIS.GeneralSpacePathTemplate, "treetime_accounting": true, "treesize_accounting": true, "permissionssvc": cfg.Drivers.OCIS.PermissionsEndpoint, @@ -203,7 +205,9 @@ func OcisNoEvents(cfg *config.Config) map[string]interface{} { "user_layout": cfg.Drivers.OCIS.UserLayout, "share_folder": cfg.Drivers.OCIS.ShareFolder, "personalspacealias_template": cfg.Drivers.OCIS.PersonalSpaceAliasTemplate, + "personalspacepath_template": cfg.Drivers.OCIS.PersonalSpacePathTemplate, "generalspacealias_template": cfg.Drivers.OCIS.GeneralSpaceAliasTemplate, + "generalspacepath_template": cfg.Drivers.OCIS.GeneralSpacePathTemplate, "treetime_accounting": true, "treesize_accounting": true, "permissionssvc": cfg.Drivers.OCIS.PermissionsEndpoint, @@ -259,8 +263,10 @@ func S3NG(cfg *config.Config) map[string]interface{} { "root": cfg.Drivers.S3NG.Root, "user_layout": cfg.Drivers.S3NG.UserLayout, "share_folder": cfg.Drivers.S3NG.ShareFolder, - "personalspacealias_template": cfg.Drivers.S3NG.PersonalSpaceAliasTemplate, - "generalspacealias_template": cfg.Drivers.S3NG.GeneralSpaceAliasTemplate, + "personalspacealias_template": cfg.Drivers.OCIS.PersonalSpaceAliasTemplate, + "personalspacepath_template": cfg.Drivers.OCIS.PersonalSpacePathTemplate, + "generalspacealias_template": cfg.Drivers.OCIS.GeneralSpaceAliasTemplate, + "generalspacepath_template": cfg.Drivers.OCIS.GeneralSpacePathTemplate, "treetime_accounting": true, "treesize_accounting": true, "permissionssvc": cfg.Drivers.S3NG.PermissionsEndpoint, @@ -323,8 +329,10 @@ func S3NGNoEvents(cfg *config.Config) map[string]interface{} { "root": cfg.Drivers.S3NG.Root, "user_layout": cfg.Drivers.S3NG.UserLayout, "share_folder": cfg.Drivers.S3NG.ShareFolder, - "personalspacealias_template": cfg.Drivers.S3NG.PersonalSpaceAliasTemplate, - "generalspacealias_template": cfg.Drivers.S3NG.GeneralSpaceAliasTemplate, + "personalspacealias_template": cfg.Drivers.OCIS.PersonalSpaceAliasTemplate, + "personalspacepath_template": cfg.Drivers.OCIS.PersonalSpacePathTemplate, + "generalspacealias_template": cfg.Drivers.OCIS.GeneralSpaceAliasTemplate, + "generalspacepath_template": cfg.Drivers.OCIS.GeneralSpacePathTemplate, "treetime_accounting": true, "treesize_accounting": true, "permissionssvc": cfg.Drivers.S3NG.PermissionsEndpoint,