From c99861130f2a2bc66bfb953097ec73006caaa3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 1 Sep 2020 12:12:52 +0200 Subject: [PATCH] config cleanup --- docs/_index.md | 35 ++++ pkg/command/drivers.go | 95 ++++++++++ pkg/command/gateway.go | 22 +++ pkg/command/storageeos.go | 42 +---- pkg/command/storageeosdata.go | 44 +---- pkg/command/storagehome.go | 61 +------ pkg/command/storagehomedata.go | 63 +------ pkg/command/storageoc.go | 61 +------ pkg/command/storageocdata.go | 63 +------ pkg/command/storagepubliclink.go | 9 +- pkg/command/storageroot.go | 60 +------ pkg/config/config.go | 42 +++-- pkg/flagset/authbasic.go | 154 +--------------- pkg/flagset/authbearer.go | 72 +------- pkg/flagset/debug.go | 31 ++++ pkg/flagset/drivereos.go | 133 ++++++++++++++ pkg/flagset/driverlocal.go | 19 ++ pkg/flagset/driverowncloud.go | 47 +++++ pkg/flagset/frontend.go | 69 +------- pkg/flagset/gateway.go | 94 +++------- pkg/flagset/ldap.go | 134 ++++++++++++++ pkg/flagset/secret.go | 19 ++ pkg/flagset/sharing.go | 72 +------- pkg/flagset/storageeos.go | 252 ++------------------------ pkg/flagset/storageeosdata.go | 258 +++------------------------ pkg/flagset/storagehome.go | 249 ++------------------------ pkg/flagset/storagehomedata.go | 249 ++------------------------ pkg/flagset/storageoc.go | 251 ++------------------------ pkg/flagset/storageocdata.go | 251 ++------------------------ pkg/flagset/storagepubliclink.go | 142 ++------------- pkg/flagset/storageroot.go | 237 ++----------------------- pkg/flagset/tracing.go | 47 +++++ pkg/flagset/users.go | 292 +++++++------------------------ 33 files changed, 841 insertions(+), 2828 deletions(-) create mode 100644 pkg/command/drivers.go create mode 100644 pkg/flagset/debug.go create mode 100644 pkg/flagset/drivereos.go create mode 100644 pkg/flagset/driverlocal.go create mode 100644 pkg/flagset/driverowncloud.go create mode 100644 pkg/flagset/ldap.go create mode 100644 pkg/flagset/secret.go create mode 100644 pkg/flagset/tracing.go diff --git a/docs/_index.md b/docs/_index.md index 757f7f6f50..ab942240c0 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -8,3 +8,38 @@ geekdocFilePath: _index.md --- This service provides an ocis extension that wraps [reva](https://github.com/cs3org/reva/) and adds an opinionated configuration to it. + +It uses the port range 9140-9179 to preconfigure several services. + +| port | service | ++------+---------+ +| 9109 | health? | +| 9140 | frontend | +| 9141 | frontend debug | +| 9142 | gateway | +| 9143 | gateway debug | +| 9144 | users | +| 9145 | users debug | +| 9146 | authbasic | +| 9147 | authbasic debug | +| 9148 | authbearer | +| 9149 | authbearer debug | +| 9150 | sharing | +| 9151 | sharing debug | +| 9152 | storage root | +| 9153 | storage root debug | +| 9154 | storage home | +| 9155 | storage home debug | +| 9156 | storage home data | +| 9157 | storage home data debug | +| 9158 | storage eos | +| 9159 | storage eos debug | +| 9160 | storage eos data | +| 9161 | storage eos data debug | +| 9162 | storage oc | +| 9163 | storage oc debug | +| 9164 | storage oc data | +| 9165 | storage oc data debug | +| 9166-9177 | reserved for s3, wnd, custom + data providers | +| 9178 | storage public link | +| 9179 | storage public link data | diff --git a/pkg/command/drivers.go b/pkg/command/drivers.go new file mode 100644 index 0000000000..7140409b31 --- /dev/null +++ b/pkg/command/drivers.go @@ -0,0 +1,95 @@ +package command + +import ( + "github.com/owncloud/ocis-reva/pkg/config" +) + +func drivers(cfg *config.Config) map[string]interface{} { + return map[string]interface{}{ + "eos": map[string]interface{}{ + "namespace": cfg.Reva.Storages.Common.Root, + "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, + "uploads_namespace": cfg.Reva.Storages.EOS.UploadsNamespace, + "share_folder": cfg.Reva.Storages.Common.ShareFolder, + "eos_binary": cfg.Reva.Storages.EOS.EosBinary, + "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, + "master_url": cfg.Reva.Storages.EOS.MasterURL, + "slave_url": cfg.Reva.Storages.EOS.SlaveURL, + "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, + "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, + "keytab": cfg.Reva.Storages.EOS.Keytab, + "single_username": cfg.Reva.Storages.EOS.SingleUsername, + "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, + "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, + "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, + "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, + "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, + }, + "eoshome": map[string]interface{}{ + "namespace": cfg.Reva.Storages.Common.Root, + "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, + "uploads_namespace": cfg.Reva.Storages.EOS.UploadsNamespace, + "share_folder": cfg.Reva.Storages.Common.ShareFolder, + "eos_binary": cfg.Reva.Storages.EOS.EosBinary, + "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, + "master_url": cfg.Reva.Storages.EOS.MasterURL, + "slave_url": cfg.Reva.Storages.EOS.SlaveURL, + "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, + "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, + "keytab": cfg.Reva.Storages.EOS.Keytab, + "single_username": cfg.Reva.Storages.EOS.SingleUsername, + "user_layout": cfg.Reva.Storages.Common.UserLayout, + "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, + "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, + "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, + "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, + "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, + }, + "eosgrpc": map[string]interface{}{ + "namespace": cfg.Reva.Storages.Common.Root, + "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, + "share_folder": cfg.Reva.Storages.Common.ShareFolder, + "eos_binary": cfg.Reva.Storages.EOS.EosBinary, + "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, + "master_url": cfg.Reva.Storages.EOS.MasterURL, + "master_grpc_uri": cfg.Reva.Storages.EOS.GrpcURI, + "slave_url": cfg.Reva.Storages.EOS.SlaveURL, + "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, + "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, + "keytab": cfg.Reva.Storages.EOS.Keytab, + "single_username": cfg.Reva.Storages.EOS.SingleUsername, + "user_layout": cfg.Reva.Storages.Common.UserLayout, + "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, + "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, + "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, + "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, + "enable_home": cfg.Reva.Storages.Common.EnableHome, + "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, + }, + "local": map[string]interface{}{ + "root": cfg.Reva.Storages.Common.Root, + "share_folder": cfg.Reva.Storages.Common.ShareFolder, + }, + "localhome": map[string]interface{}{ + "root": cfg.Reva.Storages.Common.Root, + "share_folder": cfg.Reva.Storages.Common.ShareFolder, + "user_layout": cfg.Reva.Storages.Common.UserLayout, + }, + "owncloud": map[string]interface{}{ + "datadirectory": cfg.Reva.Storages.Common.Root, + "scan": cfg.Reva.Storages.OwnCloud.Scan, + "redis": cfg.Reva.Storages.OwnCloud.Redis, + "enable_home": cfg.Reva.Storages.Common.EnableHome, + "user_layout": cfg.Reva.Storages.Common.UserLayout, + "userprovidersvc": cfg.Reva.Users.URL, + }, + "s3": map[string]interface{}{ + "region": cfg.Reva.Storages.S3.Region, + "access_key": cfg.Reva.Storages.S3.AccessKey, + "secret_key": cfg.Reva.Storages.S3.SecretKey, + "endpoint": cfg.Reva.Storages.S3.Endpoint, + "bucket": cfg.Reva.Storages.S3.Bucket, + "prefix": cfg.Reva.Storages.Common.Root, + }, + } +} diff --git a/pkg/command/gateway.go b/pkg/command/gateway.go index 842063bcd3..f2f7644e9f 100644 --- a/pkg/command/gateway.go +++ b/pkg/command/gateway.go @@ -241,3 +241,25 @@ func Gateway(cfg *config.Config) *cli.Command { }, } } + +func rules(cfg *config.Config) map[string]interface{} { + + return map[string]interface{}{ + cfg.Reva.StorageRoot.MountPath: cfg.Reva.StorageRoot.URL, + cfg.Reva.StorageRoot.MountID: cfg.Reva.StorageRoot.URL, + cfg.Reva.StorageHome.MountPath: cfg.Reva.StorageHome.URL, + cfg.Reva.StorageHome.MountID: cfg.Reva.StorageHome.URL, + cfg.Reva.StorageEOS.MountPath: cfg.Reva.StorageEOS.URL, + cfg.Reva.StorageEOS.MountID: cfg.Reva.StorageEOS.URL, + cfg.Reva.StorageOC.MountPath: cfg.Reva.StorageOC.URL, + cfg.Reva.StorageOC.MountID: cfg.Reva.StorageOC.URL, + cfg.Reva.StorageS3.MountPath: cfg.Reva.StorageS3.URL, + cfg.Reva.StorageS3.MountID: cfg.Reva.StorageS3.URL, + cfg.Reva.StorageWND.MountPath: cfg.Reva.StorageWND.URL, + cfg.Reva.StorageWND.MountID: cfg.Reva.StorageWND.URL, + cfg.Reva.StorageCustom.MountPath: cfg.Reva.StorageCustom.URL, + cfg.Reva.StorageCustom.MountID: cfg.Reva.StorageCustom.URL, + cfg.Reva.StoragePublicLink.MountPath: cfg.Reva.StoragePublicLink.URL, + cfg.Reva.StoragePublicLink.MountID: cfg.Reva.StoragePublicLink.URL, + } +} diff --git a/pkg/command/storageeos.go b/pkg/command/storageeos.go index 643fdbbaf4..6fab0e7636 100644 --- a/pkg/command/storageeos.go +++ b/pkg/command/storageeos.go @@ -87,46 +87,8 @@ func StorageEOS(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageEOS.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - }, + "driver": cfg.Reva.StorageEOS.Driver, + "drivers": drivers(cfg), "mount_path": cfg.Reva.StorageEOS.MountPath, "mount_id": cfg.Reva.StorageEOS.MountID, "expose_data_server": cfg.Reva.StorageEOS.ExposeDataServer, diff --git a/pkg/command/storageeosdata.go b/pkg/command/storageeosdata.go index 3f208d0a50..e939e01274 100644 --- a/pkg/command/storageeosdata.go +++ b/pkg/command/storageeosdata.go @@ -88,47 +88,9 @@ func StorageEOSData(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "dataprovider": map[string]interface{}{ - "prefix": cfg.Reva.StorageEOSData.Prefix, - "driver": cfg.Reva.StorageEOSData.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - }, + "prefix": cfg.Reva.StorageEOSData.Prefix, + "driver": cfg.Reva.StorageEOSData.Driver, + "drivers": drivers(cfg), "timeout": 86400, "insecure": true, "disable_tus": false, diff --git a/pkg/command/storagehome.go b/pkg/command/storagehome.go index 4a67679742..c528ff8a81 100644 --- a/pkg/command/storagehome.go +++ b/pkg/command/storagehome.go @@ -87,65 +87,8 @@ func StorageHome(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageHome.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "local": map[string]interface{}{ - "root": cfg.Reva.Storages.Local.Root, - }, - "owncloud": map[string]interface{}{ - "datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory, - "scan": cfg.Reva.Storages.OwnCloud.Scan, - "redis": cfg.Reva.Storages.OwnCloud.Redis, - "enable_home": true, - "user_layout": cfg.Reva.Storages.OwnCloud.Layout, - "userprovidersvc": cfg.Reva.Users.URL, - }, - "s3": map[string]interface{}{ - "region": cfg.Reva.Storages.S3.Region, - "access_key": cfg.Reva.Storages.S3.AccessKey, - "secret_key": cfg.Reva.Storages.S3.SecretKey, - "endpoint": cfg.Reva.Storages.S3.Endpoint, - "bucket": cfg.Reva.Storages.S3.Bucket, - "prefix": cfg.Reva.Storages.S3.Prefix, - }, - }, + "driver": cfg.Reva.StorageHome.Driver, + "drivers": drivers(cfg), "mount_path": cfg.Reva.StorageHome.MountPath, "mount_id": cfg.Reva.StorageHome.MountID, "expose_data_server": cfg.Reva.StorageHome.ExposeDataServer, diff --git a/pkg/command/storagehomedata.go b/pkg/command/storagehomedata.go index 8c622e76a3..6f909bd2d9 100644 --- a/pkg/command/storagehomedata.go +++ b/pkg/command/storagehomedata.go @@ -88,66 +88,9 @@ func StorageHomeData(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "dataprovider": map[string]interface{}{ - "prefix": cfg.Reva.StorageHomeData.Prefix, - "driver": cfg.Reva.StorageHomeData.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "local": map[string]interface{}{ - "root": cfg.Reva.Storages.Local.Root, - }, - "owncloud": map[string]interface{}{ - "datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory, - "scan": cfg.Reva.Storages.OwnCloud.Scan, - "redis": cfg.Reva.Storages.OwnCloud.Redis, - "enable_home": cfg.Reva.Storages.OwnCloud.EnableHome, - "user_layout": cfg.Reva.Storages.OwnCloud.Layout, - "userprovidersvc": cfg.Reva.Users.URL, - }, - "s3": map[string]interface{}{ - "region": cfg.Reva.Storages.S3.Region, - "access_key": cfg.Reva.Storages.S3.AccessKey, - "secret_key": cfg.Reva.Storages.S3.SecretKey, - "endpoint": cfg.Reva.Storages.S3.Endpoint, - "bucket": cfg.Reva.Storages.S3.Bucket, - "prefix": cfg.Reva.Storages.S3.Prefix, - }, - }, + "prefix": cfg.Reva.StorageHomeData.Prefix, + "driver": cfg.Reva.StorageHomeData.Driver, + "drivers": drivers(cfg), "timeout": 86400, "insecure": true, "disable_tus": false, diff --git a/pkg/command/storageoc.go b/pkg/command/storageoc.go index 01bc7a9fd1..dfe39702b4 100644 --- a/pkg/command/storageoc.go +++ b/pkg/command/storageoc.go @@ -87,65 +87,8 @@ func StorageOC(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageOC.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "local": map[string]interface{}{ - "root": cfg.Reva.Storages.Local.Root, - }, - "owncloud": map[string]interface{}{ - "datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory, - "scan": cfg.Reva.Storages.OwnCloud.Scan, - "redis": cfg.Reva.Storages.OwnCloud.Redis, - "enable_home": cfg.Reva.Storages.OwnCloud.EnableHome, - "user_layout": cfg.Reva.Storages.OwnCloud.Layout, - "userprovidersvc": cfg.Reva.Users.URL, - }, - "s3": map[string]interface{}{ - "region": cfg.Reva.Storages.S3.Region, - "access_key": cfg.Reva.Storages.S3.AccessKey, - "secret_key": cfg.Reva.Storages.S3.SecretKey, - "endpoint": cfg.Reva.Storages.S3.Endpoint, - "bucket": cfg.Reva.Storages.S3.Bucket, - "prefix": cfg.Reva.Storages.S3.Prefix, - }, - }, + "driver": cfg.Reva.StorageOC.Driver, + "drivers": drivers(cfg), "mount_path": cfg.Reva.StorageOC.MountPath, "mount_id": cfg.Reva.StorageOC.MountID, "expose_data_server": cfg.Reva.StorageOC.ExposeDataServer, diff --git a/pkg/command/storageocdata.go b/pkg/command/storageocdata.go index 35cac2d1d3..414069d15c 100644 --- a/pkg/command/storageocdata.go +++ b/pkg/command/storageocdata.go @@ -88,66 +88,9 @@ func StorageOCData(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "dataprovider": map[string]interface{}{ - "prefix": cfg.Reva.StorageOCData.Prefix, - "driver": cfg.Reva.StorageOCData.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "local": map[string]interface{}{ - "root": cfg.Reva.Storages.Local.Root, - }, - "owncloud": map[string]interface{}{ - "datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory, - "scan": cfg.Reva.Storages.OwnCloud.Scan, - "redis": cfg.Reva.Storages.OwnCloud.Redis, - "enable_home": cfg.Reva.Storages.OwnCloud.EnableHome, - "user_layout": cfg.Reva.Storages.OwnCloud.Layout, - "userprovidersvc": cfg.Reva.Users.URL, - }, - "s3": map[string]interface{}{ - "region": cfg.Reva.Storages.S3.Region, - "access_key": cfg.Reva.Storages.S3.AccessKey, - "secret_key": cfg.Reva.Storages.S3.SecretKey, - "endpoint": cfg.Reva.Storages.S3.Endpoint, - "bucket": cfg.Reva.Storages.S3.Bucket, - "prefix": cfg.Reva.Storages.S3.Prefix, - }, - }, + "prefix": cfg.Reva.StorageOCData.Prefix, + "driver": cfg.Reva.StorageOCData.Driver, + "drivers": drivers(cfg), "timeout": 86400, "insecure": true, "disable_tus": false, diff --git a/pkg/command/storagepubliclink.go b/pkg/command/storagepubliclink.go index d40313156f..21bcd6abd6 100644 --- a/pkg/command/storagepubliclink.go +++ b/pkg/command/storagepubliclink.go @@ -68,8 +68,11 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { rcfg := map[string]interface{}{ "core": map[string]interface{}{ - "max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs, - "tracing_enabled": true, + "max_cpus": cfg.Reva.StoragePublicLink.MaxCPUs, + "tracing_enabled": cfg.Tracing.Enabled, + "tracing_endpoint": cfg.Tracing.Endpoint, + "tracing_collector": cfg.Tracing.Collector, + "tracing_service_name": "storage-public-link", }, "shared": map[string]interface{}{ "jwt_secret": cfg.Reva.JWTSecret, @@ -83,8 +86,6 @@ func StoragePublicLink(cfg *config.Config) *cli.Command { "services": map[string]interface{}{ "publicstorageprovider": map[string]interface{}{ "mount_path": cfg.Reva.StoragePublicLink.MountPath, - "mount_id": cfg.Reva.StoragePublicLink.MountID, - "driver_addr": cfg.Reva.StoragePublicLink.PublicShareProviderAddr, "gateway_addr": cfg.Reva.Gateway.URL, }, "authprovider": map[string]interface{}{ diff --git a/pkg/command/storageroot.go b/pkg/command/storageroot.go index f63d23b6d0..ed9968018e 100644 --- a/pkg/command/storageroot.go +++ b/pkg/command/storageroot.go @@ -87,64 +87,8 @@ func StorageRoot(cfg *config.Config) *cli.Command { // TODO build services dynamically "services": map[string]interface{}{ "storageprovider": map[string]interface{}{ - "driver": cfg.Reva.StorageRoot.Driver, - "drivers": map[string]interface{}{ - "eos": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "eoshome": map[string]interface{}{ - "namespace": cfg.Reva.Storages.EOS.Namespace, - "shadow_namespace": cfg.Reva.Storages.EOS.ShadowNamespace, - "share_folder": cfg.Reva.Storages.EOS.ShareFolder, - "eos_binary": cfg.Reva.Storages.EOS.EosBinary, - "xrdcopy_binary": cfg.Reva.Storages.EOS.XrdcopyBinary, - "master_url": cfg.Reva.Storages.EOS.MasterURL, - "slave_url": cfg.Reva.Storages.EOS.SlaveURL, - "cache_directory": cfg.Reva.Storages.EOS.CacheDirectory, - "enable_logging": cfg.Reva.Storages.EOS.EnableLogging, - "show_hidden_sys_files": cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - "force_single_user_mode": cfg.Reva.Storages.EOS.ForceSingleUserMode, - "use_keytab": cfg.Reva.Storages.EOS.UseKeytab, - "sec_protocol": cfg.Reva.Storages.EOS.SecProtocol, - "keytab": cfg.Reva.Storages.EOS.Keytab, - "single_username": cfg.Reva.Storages.EOS.SingleUsername, - "user_layout": cfg.Reva.Storages.EOS.Layout, - "gatewaysvc": cfg.Reva.Storages.EOS.GatewaySVC, - }, - "local": map[string]interface{}{ - "root": cfg.Reva.Storages.Local.Root, - }, - "owncloud": map[string]interface{}{ - "datadirectory": cfg.Reva.Storages.OwnCloud.Datadirectory, - "scan": cfg.Reva.Storages.OwnCloud.Scan, - "redis": cfg.Reva.Storages.OwnCloud.Redis, - "enable_home": cfg.Reva.Storages.OwnCloud.EnableHome, - "user_layout": cfg.Reva.Storages.OwnCloud.Layout, - }, - "s3": map[string]interface{}{ - "region": cfg.Reva.Storages.S3.Region, - "access_key": cfg.Reva.Storages.S3.AccessKey, - "secret_key": cfg.Reva.Storages.S3.SecretKey, - "endpoint": cfg.Reva.Storages.S3.Endpoint, - "bucket": cfg.Reva.Storages.S3.Bucket, - "prefix": cfg.Reva.Storages.S3.Prefix, - }, - }, + "driver": cfg.Reva.StorageRoot.Driver, + "drivers": drivers(cfg), "mount_path": cfg.Reva.StorageRoot.MountPath, "mount_id": cfg.Reva.StorageRoot.MountID, "expose_data_server": cfg.Reva.StorageRoot.ExposeDataServer, diff --git a/pkg/config/config.go b/pkg/config/config.go index 6bb8cc5e0b..71bcaf1130 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -94,9 +94,7 @@ type PublicStorage struct { StoragePort PublicShareProviderAddr string - StorageProviderAddr string UserProviderAddr string - MountID string } // StorageConfig combines all available storage driver configuration parts. @@ -105,20 +103,18 @@ type StorageConfig struct { Local DriverLocal OwnCloud DriverOwnCloud S3 DriverS3 + Common DriverCommon // TODO checksums ... figure out what that is supposed to do } // DriverEOS defines the available EOS driver configuration. type DriverEOS struct { - // Namespace for metadata operations - Namespace string // ShadowNamespace for storing shadow data ShadowNamespace string - // ShareFolder defines the name of the folder in the - // shadowed namespace. Ex: /eos/user/.shadow/h/hugo/MyShares - ShareFolder string + // UploadsNamespace for storing upload data + UploadsNamespace string // Location of the eos binary. // Default is /usr/bin/eos. @@ -132,6 +128,10 @@ type DriverEOS struct { // Default is root://eos-example.org MasterURL string + // URI of the EOS MGM grpc server + // Default is empty + GrpcURI string + // URL of the Slave EOS MGM. // Default is root://eos-example.org SlaveURL string @@ -154,9 +154,6 @@ type DriverEOS struct { // UseKeyTabAuth changes will authenticate requests by using an EOS keytab. UseKeytab bool - // EnableHome enables the creation of home directories. - EnableHome bool - // SecProtocol specifies the xrootd security protocol to use between the server and EOS. SecProtocol string @@ -166,9 +163,6 @@ type DriverEOS struct { // SingleUsername is the username to use when SingleUserMode is enabled SingleUsername string - // Layout of the users home dir path - Layout string - // gateway service to use for uid lookups GatewaySVC string } @@ -178,13 +172,23 @@ type DriverLocal struct { Root string } +// DriverCommon defines common driver configuration options. +type DriverCommon struct { + // Root is the absolute path to the location of the data + Root string + //ShareFolder defines the name of the folder jailing all shares + ShareFolder string + // UserLayout contains the template used to construct + // the internal path, eg: `{{substr 0 1 .Username}}/{{.Username}}` + UserLayout string + // EnableHome enables the creation of home directories. + EnableHome bool +} + // DriverOwnCloud defines the available ownCloud storage driver configuration. type DriverOwnCloud struct { - Datadirectory string - Layout string - Redis string - Scan bool - EnableHome bool + Redis string + Scan bool } // DriverS3 defines the available S3 storage driver configuration. @@ -194,7 +198,6 @@ type DriverS3 struct { SecretKey string Endpoint string Bucket string - Prefix string } // OIDC defines the available OpenID Connect configuration. @@ -273,6 +276,7 @@ type Reva struct { AuthBearer Port Sharing Sharing StorageRoot StoragePort + StorageRootData StoragePort StorageHome StoragePort StorageHomeData StoragePort StorageEOS StoragePort diff --git a/pkg/flagset/authbasic.go b/pkg/flagset/authbasic.go index 4e10a77550..09ee616fbf 100644 --- a/pkg/flagset/authbasic.go +++ b/pkg/flagset/authbasic.go @@ -7,42 +7,7 @@ import ( // AuthBasicWithConfig applies cfg to the root flagset func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,35 +17,6 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_AUTH_BASIC_DEBUG_ADDR"}, Destination: &cfg.Reva.AuthBasic.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Auth @@ -99,87 +35,6 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.AuthProvider.JSON, }, - // LDAP - - &cli.StringFlag{ - Name: "ldap-hostname", - Value: "localhost", - Usage: "LDAP hostname", - EnvVars: []string{"REVA_LDAP_HOSTNAME"}, - Destination: &cfg.Reva.LDAP.Hostname, - }, - &cli.IntFlag{ - Name: "ldap-port", - Value: 9126, - Usage: "LDAP port", - EnvVars: []string{"REVA_LDAP_PORT"}, - Destination: &cfg.Reva.LDAP.Port, - }, - &cli.StringFlag{ - Name: "ldap-base-dn", - Value: "dc=example,dc=org", - Usage: "LDAP basedn", - EnvVars: []string{"REVA_LDAP_BASE_DN"}, - Destination: &cfg.Reva.LDAP.BaseDN, - }, - &cli.StringFlag{ - Name: "ldap-loginfilter", - Value: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", - Usage: "LDAP login filter", - EnvVars: []string{"REVA_LDAP_LOGINFILTER"}, - Destination: &cfg.Reva.LDAP.LoginFilter, - }, - &cli.StringFlag{ - Name: "ldap-bind-dn", - Value: "cn=reva,ou=sysusers,dc=example,dc=org", - Usage: "LDAP bind dn", - EnvVars: []string{"REVA_LDAP_BIND_DN"}, - Destination: &cfg.Reva.LDAP.BindDN, - }, - &cli.StringFlag{ - Name: "ldap-bind-password", - Value: "reva", - Usage: "LDAP bind password", - EnvVars: []string{"REVA_LDAP_BIND_PASSWORD"}, - Destination: &cfg.Reva.LDAP.BindPassword, - }, - &cli.StringFlag{ - Name: "ldap-idp", - Value: "https://localhost:9200", - Usage: "Identity provider to use for users", - EnvVars: []string{"REVA_LDAP_IDP"}, - Destination: &cfg.Reva.LDAP.IDP, - }, - // ldap dn is always the dn - &cli.StringFlag{ - Name: "ldap-schema-uid", - Value: "ownclouduuid", - Usage: "LDAP schema uid", - EnvVars: []string{"REVA_LDAP_SCHEMA_UID"}, - Destination: &cfg.Reva.LDAP.Schema.UID, - }, - &cli.StringFlag{ - Name: "ldap-schema-mail", - Value: "mail", - Usage: "LDAP schema mail", - EnvVars: []string{"REVA_LDAP_SCHEMA_MAIL"}, - Destination: &cfg.Reva.LDAP.Schema.Mail, - }, - &cli.StringFlag{ - Name: "ldap-schema-displayName", - Value: "displayname", - Usage: "LDAP schema displayName", - EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"}, - Destination: &cfg.Reva.LDAP.Schema.DisplayName, - }, - &cli.StringFlag{ - Name: "ldap-schema-cn", - Value: "cn", - Usage: "LDAP schema cn", - EnvVars: []string{"REVA_LDAP_SCHEMA_CN"}, - Destination: &cfg.Reva.LDAP.Schema.CN, - }, - // Services // AuthBasic @@ -219,4 +74,11 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_AUTH_BASIC_SERVICES"}, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, LDAPWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/authbearer.go b/pkg/flagset/authbearer.go index 17a8d07858..181032c892 100644 --- a/pkg/flagset/authbearer.go +++ b/pkg/flagset/authbearer.go @@ -7,42 +7,7 @@ import ( // AuthBearerWithConfig applies cfg to the root flagset func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,35 +17,6 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_AUTH_BEARER_DEBUG_ADDR"}, Destination: &cfg.Reva.AuthBearer.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // OIDC @@ -165,4 +101,10 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_AUTH_BEARER_SERVICES"}, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/debug.go b/pkg/flagset/debug.go new file mode 100644 index 0000000000..0056942f5d --- /dev/null +++ b/pkg/flagset/debug.go @@ -0,0 +1,31 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// DebugWithConfig applies common debug config cfg to the flagset +func DebugWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "debug-token", + Value: "", + Usage: "Token to grant metrics access", + EnvVars: []string{"REVA_DEBUG_TOKEN"}, + Destination: &cfg.Debug.Token, + }, + &cli.BoolFlag{ + Name: "debug-pprof", + Usage: "Enable pprof debugging", + EnvVars: []string{"REVA_DEBUG_PPROF"}, + Destination: &cfg.Debug.Pprof, + }, + &cli.BoolFlag{ + Name: "debug-zpages", + Usage: "Enable zpages debugging", + EnvVars: []string{"REVA_DEBUG_ZPAGES"}, + Destination: &cfg.Debug.Zpages, + }, + } +} diff --git a/pkg/flagset/drivereos.go b/pkg/flagset/drivereos.go new file mode 100644 index 0000000000..3ea27170a7 --- /dev/null +++ b/pkg/flagset/drivereos.go @@ -0,0 +1,133 @@ +package flagset + +import ( + "os" + + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// DriverEOSWithConfig applies cfg to the root flagset +func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + + &cli.StringFlag{ + Name: "storage-eos-namespace", + Value: "/eos/dockertest/reva", + Usage: "Namespace for metadata operations", + EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, + Destination: &cfg.Reva.Storages.Common.Root, + }, + &cli.StringFlag{ + Name: "storage-eos-shadow-namespace", + // Defaults to path.Join(c.Namespace, ".shadow") + Usage: "Shadow namespace where share references are stored", + EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, + Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, + }, + &cli.StringFlag{ + Name: "storage-eos-share-folder", + Value: "/Shares", + Usage: "name of the share folder", + EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, + Destination: &cfg.Reva.Storages.Common.ShareFolder, + }, + &cli.StringFlag{ + Name: "storage-eos-binary", + Value: "/usr/bin/eos", + Usage: "Location of the eos binary", + EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, + Destination: &cfg.Reva.Storages.EOS.EosBinary, + }, + &cli.StringFlag{ + Name: "storage-eos-xrdcopy-binary", + Value: "/usr/bin/xrdcopy", + Usage: "Location of the xrdcopy binary", + EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, + Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, + }, + &cli.StringFlag{ + Name: "storage-eos-master-url", + Value: "root://eos-mgm1.eoscluster.cern.ch:1094", + Usage: "URL of the Master EOS MGM", + EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, + Destination: &cfg.Reva.Storages.EOS.MasterURL, + }, + &cli.StringFlag{ + Name: "storage-eos-slave-url", + Value: "root://eos-mgm1.eoscluster.cern.ch:1094", + Usage: "URL of the Slave EOS MGM", + EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, + Destination: &cfg.Reva.Storages.EOS.SlaveURL, + }, + &cli.StringFlag{ + Name: "storage-eos-cache-directory", + Value: os.TempDir(), + Usage: "Location on the local fs where to store reads", + EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, + Destination: &cfg.Reva.Storages.EOS.CacheDirectory, + }, + &cli.BoolFlag{ + Name: "storage-eos-enable-logging", + Usage: "Enables logging of the commands executed", + EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, + Destination: &cfg.Reva.Storages.EOS.EnableLogging, + }, + &cli.BoolFlag{ + Name: "storage-eos-show-hidden-sysfiles", + Usage: "show internal EOS files like .sys.v# and .sys.a# files.", + EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, + Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, + }, + &cli.BoolFlag{ + Name: "storage-eos-force-singleuser-mode", + Usage: "force connections to EOS to use SingleUsername", + EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, + Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, + }, + &cli.BoolFlag{ + Name: "storage-eos-use-keytab", + Usage: "authenticate requests by using an EOS keytab", + EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, + Destination: &cfg.Reva.Storages.EOS.UseKeytab, + }, + &cli.BoolFlag{ + Name: "storage-eos-enable-home", + Usage: "enable the creation of home directories", + EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, + Destination: &cfg.Reva.Storages.Common.EnableHome, + }, + &cli.StringFlag{ + Name: "storage-eos-sec-protocol", + Usage: "the xrootd security protocol to use between the server and EOS", + EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, + Destination: &cfg.Reva.Storages.EOS.SecProtocol, + }, + &cli.StringFlag{ + Name: "storage-eos-keytab", + Usage: "the location of the keytab to use to authenticate to EOS", + EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, + Destination: &cfg.Reva.Storages.EOS.Keytab, + }, + &cli.StringFlag{ + Name: "storage-eos-single-username", + Usage: "the username to use when SingleUserMode is enabled", + EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, + Destination: &cfg.Reva.Storages.EOS.SingleUsername, + }, + &cli.StringFlag{ + Name: "storage-eos-layout", + Value: "{{substr 0 1 .Username}}/{{.Username}}", + Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, + EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, + Destination: &cfg.Reva.Storages.Common.UserLayout, + }, + &cli.StringFlag{ + Name: "storage-eos-gatewaysvc", + Value: "localhost:9142", + Usage: "URL to use for the reva gateway service", + EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, + Destination: &cfg.Reva.Storages.EOS.GatewaySVC, + }, + } +} diff --git a/pkg/flagset/driverlocal.go b/pkg/flagset/driverlocal.go new file mode 100644 index 0000000000..ba8eda4da6 --- /dev/null +++ b/pkg/flagset/driverlocal.go @@ -0,0 +1,19 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// DriverLocalWithConfig applies cfg to the root flagset +func DriverLocalWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "storage-local-root", + Value: "/var/tmp/reva/root", + Usage: "the path to the local storage root", + EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, + Destination: &cfg.Reva.Storages.Local.Root, + }, + } +} diff --git a/pkg/flagset/driverowncloud.go b/pkg/flagset/driverowncloud.go new file mode 100644 index 0000000000..a33e94d41e --- /dev/null +++ b/pkg/flagset/driverowncloud.go @@ -0,0 +1,47 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// DriverOwnCloudWithConfig applies cfg to the root flagset +func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "storage-owncloud-datadir", + Value: "/var/tmp/reva/data", + Usage: "the path to the owncloud data directory", + EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, + Destination: &cfg.Reva.Storages.Common.Root, + }, + &cli.BoolFlag{ + Name: "storage-owncloud-scan", + Value: true, + Usage: "scan files on startup to add fileids", + EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, + Destination: &cfg.Reva.Storages.OwnCloud.Scan, + }, + &cli.StringFlag{ + Name: "storage-owncloud-redis", + Value: ":6379", + Usage: "the address of the redis server", + EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, + Destination: &cfg.Reva.Storages.OwnCloud.Redis, + }, + &cli.BoolFlag{ + Name: "storage-owncloud-enable-home", + Value: false, + Usage: "enable the creation of home storages", + EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, + Destination: &cfg.Reva.Storages.Common.EnableHome, + }, + &cli.StringFlag{ + Name: "storage-owncloud-layout", + Value: "{{.Id.OpaqueId}}", + Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, + EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, + Destination: &cfg.Reva.Storages.Common.UserLayout, + }, + } +} diff --git a/pkg/flagset/frontend.go b/pkg/flagset/frontend.go index 94ec4a9347..5dbd7b2220 100644 --- a/pkg/flagset/frontend.go +++ b/pkg/flagset/frontend.go @@ -7,42 +7,7 @@ import ( // FrontendWithConfig applies cfg to the root flagset func FrontendWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,35 +17,9 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_FRONTEND_DEBUG_ADDR"}, Destination: &cfg.Reva.Frontend.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, // REVA - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, &cli.StringFlag{ Name: "transfer-secret", Value: "replace-me-with-a-transfer-secret", @@ -202,4 +141,10 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.UploadHTTPMethodOverride, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/gateway.go b/pkg/flagset/gateway.go index 68c9838a3f..0da9e9df05 100644 --- a/pkg/flagset/gateway.go +++ b/pkg/flagset/gateway.go @@ -7,42 +7,7 @@ import ( // GatewayWithConfig applies cfg to the root flagset func GatewayWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,35 +17,9 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_GATEWAY_DEBUG_ADDR"}, Destination: &cfg.Reva.Gateway.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, // REVA - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, &cli.StringFlag{ Name: "transfer-secret", Value: "replace-me-with-a-transfer-secret", @@ -229,6 +168,13 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Sharing.URL, }, + &cli.StringSliceFlag{ + Name: "storage-registry-rule", + Value: cli.NewStringSlice(), + Usage: `Replace 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{"REVA_STORAGE_REGISTRY_RULES"}, + }, + &cli.StringFlag{ Name: "storage-root-url", Value: "localhost:9152", @@ -266,11 +212,8 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageHome.MountPath, }, &cli.StringFlag{ - Name: "storage-home-mount-id", - // This is tho mount id of the /oc storage - // set it to 1284d238-aa92-42ce-bdc4-0b0000009158 for /eos - // Value: "1284d238-aa92-42ce-bdc4-0b0000009162", /os - Value: "1284d238-aa92-42ce-bdc4-0b0000009154", // /home + Name: "storage-home-mount-id", + Value: "1284d238-aa92-42ce-bdc4-0b0000009154", Usage: "mount id", EnvVars: []string{"REVA_STORAGE_HOME_MOUNT_ID"}, Destination: &cfg.Reva.StorageHome.MountID, @@ -319,12 +262,27 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_OC_MOUNT_ID"}, Destination: &cfg.Reva.StorageOC.MountID, }, + &cli.StringFlag{ - Name: "public-links-url", + Name: "public-link-url", Value: "localhost:10054", Usage: "URL to use for the public links service", EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_URL"}, Destination: &cfg.Reva.StoragePublicLink.URL, }, + &cli.StringFlag{ + Name: "storage-public-link-mount-path", + Value: "/public/", + Usage: "mount path", + EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_MOUNT_PATH"}, + Destination: &cfg.Reva.StoragePublicLink.MountPath, + }, + // public-link has no mount id } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/ldap.go b/pkg/flagset/ldap.go new file mode 100644 index 0000000000..0aa54693f9 --- /dev/null +++ b/pkg/flagset/ldap.go @@ -0,0 +1,134 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// LDAPWithConfig applies LDAP cfg to the flagset +func LDAPWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "ldap-hostname", + Value: "localhost", + Usage: "LDAP hostname", + EnvVars: []string{"REVA_LDAP_HOSTNAME"}, + Destination: &cfg.Reva.LDAP.Hostname, + }, + &cli.IntFlag{ + Name: "ldap-port", + Value: 9126, + Usage: "LDAP port", + EnvVars: []string{"REVA_LDAP_PORT"}, + Destination: &cfg.Reva.LDAP.Port, + }, + &cli.StringFlag{ + Name: "ldap-base-dn", + Value: "dc=example,dc=org", + Usage: "LDAP basedn", + EnvVars: []string{"REVA_LDAP_BASE_DN"}, + Destination: &cfg.Reva.LDAP.BaseDN, + }, + &cli.StringFlag{ + Name: "ldap-loginfilter", + Value: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", + Usage: "LDAP login filter", + EnvVars: []string{"REVA_LDAP_LOGINFILTER"}, + Destination: &cfg.Reva.LDAP.LoginFilter, + }, + &cli.StringFlag{ + Name: "ldap-userfilter", + Value: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + Usage: "LDAP filter used when getting a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.", + EnvVars: []string{"REVA_LDAP_USERFILTER"}, + Destination: &cfg.Reva.LDAP.UserFilter, + }, + &cli.StringFlag{ + Name: "ldap-attributefilter", + Value: "(&(objectclass=posixAccount)({{attr}}={{value}}))", + Usage: "LDAP filter used when searching for a user by claim/attribute. {{attr}} will be replaced with the attribute, {{value}} with the value.", + EnvVars: []string{"REVA_LDAP_ATTRIBUTEFILTER"}, + Destination: &cfg.Reva.LDAP.AttributeFilter, + }, + &cli.StringFlag{ + Name: "ldap-findfilter", + Value: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + Usage: "LDAP filter used when searching for recipients. {{query}} will be replaced with the search query", + EnvVars: []string{"REVA_LDAP_FINDFILTER"}, + Destination: &cfg.Reva.LDAP.FindFilter, + }, + &cli.StringFlag{ + Name: "ldap-groupfilter", + // FIXME the reva implementation needs to use the memberof overlay to get the cn when it only has the uuid, + // because the ldap schema either uses the dn or the member(of) attributes to establish membership + Value: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", // This filter will never work + Usage: "LDAP filter used when getting the groups of a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.", + EnvVars: []string{"REVA_LDAP_GROUPFILTER"}, + Destination: &cfg.Reva.LDAP.GroupFilter, + }, + &cli.StringFlag{ + Name: "ldap-bind-dn", + Value: "cn=reva,ou=sysusers,dc=example,dc=org", + Usage: "LDAP bind dn", + EnvVars: []string{"REVA_LDAP_BIND_DN"}, + Destination: &cfg.Reva.LDAP.BindDN, + }, + &cli.StringFlag{ + Name: "ldap-bind-password", + Value: "reva", + Usage: "LDAP bind password", + EnvVars: []string{"REVA_LDAP_BIND_PASSWORD"}, + Destination: &cfg.Reva.LDAP.BindPassword, + }, + &cli.StringFlag{ + Name: "ldap-idp", + Value: "https://localhost:9200", + Usage: "Identity provider to use for users", + EnvVars: []string{"REVA_LDAP_IDP"}, + Destination: &cfg.Reva.LDAP.IDP, + }, + // ldap dn is always the dn + &cli.StringFlag{ + Name: "ldap-schema-uid", + Value: "ownclouduuid", + Usage: "LDAP schema uid", + EnvVars: []string{"REVA_LDAP_SCHEMA_UID"}, + Destination: &cfg.Reva.LDAP.Schema.UID, + }, + &cli.StringFlag{ + Name: "ldap-schema-mail", + Value: "mail", + Usage: "LDAP schema mail", + EnvVars: []string{"REVA_LDAP_SCHEMA_MAIL"}, + Destination: &cfg.Reva.LDAP.Schema.Mail, + }, + &cli.StringFlag{ + Name: "ldap-schema-displayName", + Value: "displayname", + Usage: "LDAP schema displayName", + EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"}, + Destination: &cfg.Reva.LDAP.Schema.DisplayName, + }, + &cli.StringFlag{ + Name: "ldap-schema-cn", + Value: "cn", + Usage: "LDAP schema cn", + EnvVars: []string{"REVA_LDAP_SCHEMA_CN"}, + Destination: &cfg.Reva.LDAP.Schema.CN, + }, + &cli.StringFlag{ + Name: "ldap-schema-uidnumber", + Value: "uidnumber", + Usage: "LDAP schema uidnumber", + EnvVars: []string{"REVA_LDAP_SCHEMA_UID_NUMBER"}, + Destination: &cfg.Reva.LDAP.Schema.UIDNumber, + }, + &cli.StringFlag{ + Name: "ldap-schema-gidnumber", + Value: "gidnumber", + Usage: "LDAP schema gidnumber", + EnvVars: []string{"REVA_LDAP_SCHEMA_GIDNUMBER"}, + Destination: &cfg.Reva.LDAP.Schema.GIDNumber, + }, + } +} diff --git a/pkg/flagset/secret.go b/pkg/flagset/secret.go new file mode 100644 index 0000000000..deaa83aa74 --- /dev/null +++ b/pkg/flagset/secret.go @@ -0,0 +1,19 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// SecretWithConfig applies cfg to the root flagset +func SecretWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + &cli.StringFlag{ + Name: "jwt-secret", + Value: "Pive-Fumkiu4", + Usage: "Shared jwt secret for reva service communication", + EnvVars: []string{"REVA_JWT_SECRET"}, + Destination: &cfg.Reva.JWTSecret, + }, + } +} diff --git a/pkg/flagset/sharing.go b/pkg/flagset/sharing.go index b6f5420c2e..34252bf976 100644 --- a/pkg/flagset/sharing.go +++ b/pkg/flagset/sharing.go @@ -7,42 +7,7 @@ import ( // SharingWithConfig applies cfg to the root flagset func SharingWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,35 +17,6 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_SHARING_DEBUG_ADDR"}, Destination: &cfg.Reva.Sharing.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -142,4 +78,10 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Sharing.PublicDriver, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storageeos.go b/pkg/flagset/storageeos.go index 29414ad747..51c95f04e4 100644 --- a/pkg/flagset/storageeos.go +++ b/pkg/flagset/storageeos.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageEOSWithConfig applies cfg to the root flagset func StorageEOSWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,39 +17,8 @@ func StorageEOSWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_EOS_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageEOS.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, - - // Services - - // Storage oc + // Storage eos &cli.StringFlag{ Name: "network", @@ -165,176 +97,14 @@ func StorageEOSWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME_CREATION"}, Destination: &cfg.Reva.StorageEOS.EnableHomeCreation, }, - - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "/eos/dockertest/reva", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "/Shares", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: false, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storageeosdata.go b/pkg/flagset/storageeosdata.go index e8b5201e64..1249d64214 100644 --- a/pkg/flagset/storageeosdata.go +++ b/pkg/flagset/storageeosdata.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageEOSDataWithConfig applies cfg to the root flagset func StorageEOSDataWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageEOSDataWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_OC_DATA_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageEOSData.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -144,177 +78,6 @@ func StorageEOSDataWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageEOSData.TempFolder, }, - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "/eos/dockertest/reva", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "/Shares", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: false, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, - // Gateway &cli.StringFlag{ @@ -324,5 +87,24 @@ func StorageEOSDataWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_GATEWAY_URL"}, Destination: &cfg.Reva.Gateway.URL, }, + + // User provider + + &cli.StringFlag{ + Name: "users-url", + Value: "localhost:9144", + Usage: "URL to use for the reva service", + EnvVars: []string{"REVA_USERS_URL"}, + Destination: &cfg.Reva.Users.URL, + }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storagehome.go b/pkg/flagset/storagehome.go index 8a7b1dabf8..c771ed2686 100644 --- a/pkg/flagset/storagehome.go +++ b/pkg/flagset/storagehome.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageHomeWithConfig applies cfg to the root flagset func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_HOME_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageHome.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -170,178 +104,6 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageHome.EnableHomeCreation, }, - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "/eos/dockertest/reva/users", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "/Shares", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Value: true, - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "E/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: true, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, - // User provider &cli.StringFlag{ @@ -352,4 +114,13 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Users.URL, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storagehomedata.go b/pkg/flagset/storagehomedata.go index 70bfc2419a..494a8c50d4 100644 --- a/pkg/flagset/storagehomedata.go +++ b/pkg/flagset/storagehomedata.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageHomeDataWithConfig applies cfg to the root flagset func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_HOME_DATA_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageHomeData.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -144,178 +78,6 @@ func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageHomeData.TempFolder, }, - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "/eos/dockertest/reva/users", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "/Shares", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Value: true, - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "E/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: true, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, - // Gateway &cli.StringFlag{ @@ -336,4 +98,13 @@ func StorageHomeDataWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Users.URL, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storageoc.go b/pkg/flagset/storageoc.go index cfdc9e6237..30f3153a7a 100644 --- a/pkg/flagset/storageoc.go +++ b/pkg/flagset/storageoc.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageOCWithConfig applies cfg to the root flagset func StorageOCWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageOCWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_OC_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageOC.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -166,180 +100,6 @@ func StorageOCWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageOC.EnableHomeCreation, }, - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-example.org", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-example.org", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Value: "", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Value: "", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Value: "", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: false, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, - // User provider &cli.StringFlag{ @@ -350,4 +110,13 @@ func StorageOCWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Users.URL, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storageocdata.go b/pkg/flagset/storageocdata.go index cb27bd8b17..3952bb595b 100644 --- a/pkg/flagset/storageocdata.go +++ b/pkg/flagset/storageocdata.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageOCDataWithConfig applies cfg to the root flagset func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_OC_DATA_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageOCData.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -144,180 +78,6 @@ func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.StorageOCData.TempFolder, }, - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-shadow-namespace", - // Defaults to path.Join(c.Namespace, ".shadow") - Usage: "Shadow namespace where share references are stored", - EnvVars: []string{"REVA_STORAGE_EOS_SHADOW_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.ShadowNamespace, - }, - &cli.StringFlag{ - Name: "storage-eos-share-folder", - Value: "", - Usage: "name of the share folder", - EnvVars: []string{"REVA_STORAGE_EOS_SHARE_FOLDER"}, - Destination: &cfg.Reva.Storages.EOS.ShareFolder, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-example.org", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-example.org", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Value: "", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Value: "", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Value: "", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: false, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, - // Gateway &cli.StringFlag{ @@ -338,4 +98,13 @@ func StorageOCDataWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Users.URL, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storagepubliclink.go b/pkg/flagset/storagepubliclink.go index a665d959f7..ebe429d539 100644 --- a/pkg/flagset/storagepubliclink.go +++ b/pkg/flagset/storagepubliclink.go @@ -7,74 +7,16 @@ import ( // StoragePublicLink applies cfg to the root flagset func StoragePublicLink(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ + &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:10053", + Value: "0.0.0.0:9179", Usage: "Address to bind debug server", EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_DEBUG_ADDR"}, Destination: &cfg.Reva.StoragePublicLink.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, + &cli.StringFlag{ Name: "network", Value: "tcp", @@ -91,74 +33,19 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "addr", - Value: "localhost:10054", + Value: "0.0.0.0:9178", Usage: "Address to bind reva service", EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_ADDR"}, Destination: &cfg.Reva.StoragePublicLink.Addr, }, - &cli.StringSliceFlag{ - Name: "service", - Value: cli.NewStringSlice("storageprovider"), - Usage: "--service storageprovider [--service otherservice]", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_SERVICES"}, + &cli.StringFlag{ + Name: "url", + Value: "localhost:9178", + Usage: "Address to bind reva service", + EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_URL"}, + Destination: &cfg.Reva.StoragePublicLink.URL, }, - &cli.StringFlag{ - Name: "public_share_provider_addr", - Value: "localhost:9150", - Usage: "public share provider service address", - EnvVars: []string{"REVA_STORAGE_PUBLICLINK_PUBLIC_SHARE_PROVIDER_ADDR"}, - Destination: &cfg.Reva.StoragePublicLink.PublicShareProviderAddr, - }, - &cli.StringFlag{ - Name: "user_provider_addr", - Value: "localhost:9144", - Usage: "user provider service address", - EnvVars: []string{"REVA_STORAGE_PUBLICLINK_USER_PROVIDER_ADDR"}, - Destination: &cfg.Reva.StoragePublicLink.UserProviderAddr, - }, - &cli.StringFlag{ - Name: "storage_provider_addr", - Value: "localhost:9154", - Usage: "storage provider service address", - EnvVars: []string{"REVA_STORAGE_PUBLICLINK_STORAGE_PROVIDER_ADDR"}, - Destination: &cfg.Reva.StoragePublicLink.StorageProviderAddr, - }, - &cli.StringFlag{ - Name: "driver", - Value: "owncloud", - Usage: "storage driver, eg. local, eos, owncloud or s3", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_DRIVER"}, - Destination: &cfg.Reva.StoragePublicLink.Driver, - }, - &cli.StringFlag{ - Name: "mount-id", - Value: "e1a73ede-549b-4226-abdf-40e69ca8230d", - Usage: "mount id", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_MOUNT_ID"}, - Destination: &cfg.Reva.StoragePublicLink.MountID, - }, - &cli.BoolFlag{ - Name: "expose-data-server", - Value: false, - Usage: "exposes a dedicated data server", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_EXPOSE_DATA_SERVER"}, - Destination: &cfg.Reva.StoragePublicLink.ExposeDataServer, - }, - &cli.StringFlag{ - Name: "data-server-url", - Value: "http://localhost:9156/data", - Usage: "data server url", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_DATA_SERVER_URL"}, - Destination: &cfg.Reva.StoragePublicLink.DataServerURL, - }, - &cli.BoolFlag{ - Name: "enable-home-creation", - Value: true, - Usage: "if enabled home dirs will be automatically created", - EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_ENABLE_HOME_CREATION"}, - Destination: &cfg.Reva.StoragePublicLink.EnableHomeCreation, - }, &cli.StringFlag{ Name: "mount-path", Value: "/public/", @@ -166,6 +53,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_PUBLIC_LINK_MOUNT_PATH"}, Destination: &cfg.Reva.StoragePublicLink.MountPath, }, + &cli.StringFlag{ Name: "gateway-url", Value: "localhost:9142", @@ -174,4 +62,10 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { Destination: &cfg.Reva.Gateway.URL, }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/storageroot.go b/pkg/flagset/storageroot.go index 1c19104bbc..791f8fbd5f 100644 --- a/pkg/flagset/storageroot.go +++ b/pkg/flagset/storageroot.go @@ -1,50 +1,13 @@ package flagset import ( - "os" - "github.com/micro/cli/v2" "github.com/owncloud/ocis-reva/pkg/config" ) // StorageRootWithConfig applies cfg to the root flagset func StorageRootWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -54,35 +17,6 @@ func StorageRootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_ROOT_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageRoot.DebugAddr, }, - &cli.StringFlag{ - Name: "debug-token", - Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, - }, - - // REVA - - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, // Services @@ -163,165 +97,14 @@ func StorageRootWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_STORAGE_HOME_ENABLE_HOME_CREATION"}, Destination: &cfg.Reva.StorageHome.EnableHomeCreation, }, - - // Storage drivers - - // Eos - - &cli.StringFlag{ - Name: "storage-eos-namespace", - Value: "", - Usage: "Namespace for metadata operations", - EnvVars: []string{"REVA_STORAGE_EOS_NAMESPACE"}, - Destination: &cfg.Reva.Storages.EOS.Namespace, - }, - &cli.StringFlag{ - Name: "storage-eos-binary", - Value: "/usr/bin/eos", - Usage: "Location of the eos binary", - EnvVars: []string{"REVA_STORAGE_EOS_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.EosBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", - Usage: "Location of the xrdcopy binary", - EnvVars: []string{"REVA_STORAGE_EOS_XRDCOPY_BINARY"}, - Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, - }, - &cli.StringFlag{ - Name: "storage-eos-master-url", - Value: "root://eos-example.org", - Usage: "URL of the Master EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_MASTER_URL"}, - Destination: &cfg.Reva.Storages.EOS.MasterURL, - }, - &cli.StringFlag{ - Name: "storage-eos-slave-url", - Value: "root://eos-example.org", - Usage: "URL of the Slave EOS MGM", - EnvVars: []string{"REVA_STORAGE_EOS_SLAVE_URL"}, - Destination: &cfg.Reva.Storages.EOS.SlaveURL, - }, - &cli.StringFlag{ - Name: "storage-eos-cache-directory", - Value: os.TempDir(), - Usage: "Location on the local fs where to store reads", - EnvVars: []string{"REVA_STORAGE_EOS_CACHE_DIRECTORY"}, - Destination: &cfg.Reva.Storages.EOS.CacheDirectory, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-logging", - Usage: "Enables logging of the commands executed", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_LOGGING"}, - Destination: &cfg.Reva.Storages.EOS.EnableLogging, - }, - &cli.BoolFlag{ - Name: "storage-eos-show-hidden-sysfiles", - Usage: "show internal EOS files like .sys.v# and .sys.a# files.", - EnvVars: []string{"REVA_STORAGE_EOS_SHOW_HIDDEN_SYSFILES"}, - Destination: &cfg.Reva.Storages.EOS.ShowHiddenSysFiles, - }, - &cli.BoolFlag{ - Name: "storage-eos-force-singleuser-mode", - Usage: "force connections to EOS to use SingleUsername", - EnvVars: []string{"REVA_STORAGE_EOS_FORCE_SINGLEUSER_MODE"}, - Destination: &cfg.Reva.Storages.EOS.ForceSingleUserMode, - }, - &cli.BoolFlag{ - Name: "storage-eos-use-keytab", - Usage: "authenticate requests by using an EOS keytab", - EnvVars: []string{"REVA_STORAGE_EOS_USE_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.UseKeytab, - }, - &cli.BoolFlag{ - Name: "storage-eos-enable-home", - Usage: "enable the creation of home directories", - EnvVars: []string{"REVA_STORAGE_EOS_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.EOS.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-eos-sec-protocol", - Value: "", - Usage: "the xrootd security protocol to use between the server and EOS", - EnvVars: []string{"REVA_STORAGE_EOS_SEC_PROTOCOL"}, - Destination: &cfg.Reva.Storages.EOS.SecProtocol, - }, - &cli.StringFlag{ - Name: "storage-eos-keytab", - Value: "", - Usage: "the location of the keytab to use to authenticate to EOS", - EnvVars: []string{"REVA_STORAGE_EOS_KEYTAB"}, - Destination: &cfg.Reva.Storages.EOS.Keytab, - }, - &cli.StringFlag{ - Name: "storage-eos-single-username", - Value: "", - Usage: "the username to use when SingleUserMode is enabled", - EnvVars: []string{"REVA_STORAGE_EOS_SINGLE_USERNAME"}, - Destination: &cfg.Reva.Storages.EOS.SingleUsername, - }, - &cli.StringFlag{ - Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.UsernameLower}} and {{.Provider}} also supports prefixing dirs: "{{.UsernamePrefixCount.2}}/{{.UsernameLower}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_EOS_LAYOUT"}, - Destination: &cfg.Reva.Storages.EOS.Layout, - }, - &cli.StringFlag{ - Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", - Usage: "URL to use for the reva gateway service", - EnvVars: []string{"REVA_STORAGE_EOS_GATEWAYSVC"}, - Destination: &cfg.Reva.Storages.EOS.GatewaySVC, - }, - - // local - - &cli.StringFlag{ - Name: "storage-local-root", - Value: "/var/tmp/reva/root", - Usage: "the path to the local storage root", - EnvVars: []string{"REVA_STORAGE_LOCAL_ROOT"}, - Destination: &cfg.Reva.Storages.Local.Root, - }, - - // owncloud - - &cli.StringFlag{ - Name: "storage-owncloud-datadir", - Value: "/var/tmp/reva/data", - Usage: "the path to the owncloud data directory", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_DATADIR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Datadirectory, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-scan", - Value: true, - Usage: "scan files on startup to add fileids", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_SCAN"}, - Destination: &cfg.Reva.Storages.OwnCloud.Scan, - }, - &cli.StringFlag{ - Name: "storage-owncloud-redis", - Value: ":6379", - Usage: "the address of the redis server", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_REDIS_ADDR"}, - Destination: &cfg.Reva.Storages.OwnCloud.Redis, - }, - &cli.BoolFlag{ - Name: "storage-owncloud-enable-home", - Value: false, - Usage: "enable the creation of home storages", - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_ENABLE_HOME"}, - Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, - }, - &cli.StringFlag{ - Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", - Usage: `"layout of the users home dir path on disk, in addition to {{.Username}}, {{.Mail}}, {{.Id.OpaqueId}}, {{.Id.Idp}} also supports prefixing dirs: "{{substr 0 1 .Username}}/{{.Username}}" will turn "Einstein" into "Ei/Einstein" `, - EnvVars: []string{"REVA_STORAGE_OWNCLOUD_LAYOUT"}, - Destination: &cfg.Reva.Storages.OwnCloud.Layout, - }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, DriverEOSWithConfig(cfg)...) + flags = append(flags, DriverLocalWithConfig(cfg)...) + flags = append(flags, DriverOwnCloudWithConfig(cfg)...) + + return flags } diff --git a/pkg/flagset/tracing.go b/pkg/flagset/tracing.go new file mode 100644 index 0000000000..5c39832a8c --- /dev/null +++ b/pkg/flagset/tracing.go @@ -0,0 +1,47 @@ +package flagset + +import ( + "github.com/micro/cli/v2" + "github.com/owncloud/ocis-reva/pkg/config" +) + +// TracingWithConfig applies cfg to the root flagset +func TracingWithConfig(cfg *config.Config) []cli.Flag { + return []cli.Flag{ + + &cli.BoolFlag{ + Name: "tracing-enabled", + Usage: "Enable sending traces", + EnvVars: []string{"REVA_TRACING_ENABLED"}, + Destination: &cfg.Tracing.Enabled, + }, + &cli.StringFlag{ + Name: "tracing-type", + Value: "jaeger", + Usage: "Tracing backend type", + EnvVars: []string{"REVA_TRACING_TYPE"}, + Destination: &cfg.Tracing.Type, + }, + &cli.StringFlag{ + Name: "tracing-endpoint", + Value: "", + Usage: "Endpoint for the agent", + EnvVars: []string{"REVA_TRACING_ENDPOINT"}, + Destination: &cfg.Tracing.Endpoint, + }, + &cli.StringFlag{ + Name: "tracing-collector", + Value: "", + Usage: "Endpoint for the collector", + EnvVars: []string{"REVA_TRACING_COLLECTOR"}, + Destination: &cfg.Tracing.Collector, + }, + &cli.StringFlag{ + Name: "tracing-service", + Value: "reva", + Usage: "Service name for tracing", + EnvVars: []string{"REVA_TRACING_SERVICE"}, + Destination: &cfg.Tracing.Service, + }, + } +} diff --git a/pkg/flagset/users.go b/pkg/flagset/users.go index baaffec8b9..b54df06338 100644 --- a/pkg/flagset/users.go +++ b/pkg/flagset/users.go @@ -7,42 +7,7 @@ import ( // UsersWithConfig applies cfg to the root flagset func UsersWithConfig(cfg *config.Config) []cli.Flag { - return []cli.Flag{ - - &cli.BoolFlag{ - Name: "tracing-enabled", - Usage: "Enable sending traces", - EnvVars: []string{"REVA_TRACING_ENABLED"}, - Destination: &cfg.Tracing.Enabled, - }, - &cli.StringFlag{ - Name: "tracing-type", - Value: "jaeger", - Usage: "Tracing backend type", - EnvVars: []string{"REVA_TRACING_TYPE"}, - Destination: &cfg.Tracing.Type, - }, - &cli.StringFlag{ - Name: "tracing-endpoint", - Value: "", - Usage: "Endpoint for the agent", - EnvVars: []string{"REVA_TRACING_ENDPOINT"}, - Destination: &cfg.Tracing.Endpoint, - }, - &cli.StringFlag{ - Name: "tracing-collector", - Value: "", - Usage: "Endpoint for the collector", - EnvVars: []string{"REVA_TRACING_COLLECTOR"}, - Destination: &cfg.Tracing.Collector, - }, - &cli.StringFlag{ - Name: "tracing-service", - Value: "reva", - Usage: "Service name for tracing", - EnvVars: []string{"REVA_TRACING_SERVICE"}, - Destination: &cfg.Tracing.Service, - }, + flags := []cli.Flag{ // debug ports are the odd ports &cli.StringFlag{ @@ -52,153 +17,63 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_SHARING_DEBUG_ADDR"}, Destination: &cfg.Reva.Users.DebugAddr, }, + + // Services + + // Users + &cli.StringFlag{ - Name: "debug-token", + Name: "network", + Value: "tcp", + Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'", + EnvVars: []string{"REVA_USERS_NETWORK"}, + Destination: &cfg.Reva.Users.Network, + }, + &cli.StringFlag{ + Name: "protocol", + Value: "grpc", + Usage: "protocol for reva service, can be 'http' or 'grpc'", + EnvVars: []string{"REVA_USERS_PROTOCOL"}, + Destination: &cfg.Reva.Users.Protocol, + }, + &cli.StringFlag{ + Name: "addr", + Value: "0.0.0.0:9144", + Usage: "Address to bind reva service", + EnvVars: []string{"REVA_USERS_ADDR"}, + Destination: &cfg.Reva.Users.Addr, + }, + &cli.StringFlag{ + Name: "url", + Value: "localhost:9144", + Usage: "URL to use for the reva service", + EnvVars: []string{"REVA_USERS_URL"}, + Destination: &cfg.Reva.Users.URL, + }, + &cli.StringSliceFlag{ + Name: "service", + Value: cli.NewStringSlice("userprovider"), // TODO preferences + Usage: "--service userprovider [--service otherservice]", + EnvVars: []string{"REVA_USERS_SERVICES"}, + }, + + &cli.StringFlag{ + Name: "driver", + Value: "ldap", + Usage: "user driver: 'demo', 'json', 'ldap', or 'rest'", + EnvVars: []string{"REVA_USERS_DRIVER"}, + Destination: &cfg.Reva.Users.Driver, + }, + &cli.StringFlag{ + Name: "json-config", Value: "", - Usage: "Token to grant metrics access", - EnvVars: []string{"REVA_DEBUG_TOKEN"}, - Destination: &cfg.Debug.Token, - }, - &cli.BoolFlag{ - Name: "debug-pprof", - Usage: "Enable pprof debugging", - EnvVars: []string{"REVA_DEBUG_PPROF"}, - Destination: &cfg.Debug.Pprof, - }, - &cli.BoolFlag{ - Name: "debug-zpages", - Usage: "Enable zpages debugging", - EnvVars: []string{"REVA_DEBUG_ZPAGES"}, - Destination: &cfg.Debug.Zpages, + Usage: "Path to users.json file", + EnvVars: []string{"REVA_USERS_JSON"}, + Destination: &cfg.Reva.Users.JSON, }, - // REVA + // rest driver - &cli.StringFlag{ - Name: "jwt-secret", - Value: "Pive-Fumkiu4", - Usage: "Shared jwt secret for reva service communication", - EnvVars: []string{"REVA_JWT_SECRET"}, - Destination: &cfg.Reva.JWTSecret, - }, - - // LDAP - - &cli.StringFlag{ - Name: "ldap-hostname", - Value: "localhost", - Usage: "LDAP hostname", - EnvVars: []string{"REVA_LDAP_HOSTNAME"}, - Destination: &cfg.Reva.LDAP.Hostname, - }, - &cli.IntFlag{ - Name: "ldap-port", - Value: 9126, - Usage: "LDAP port", - EnvVars: []string{"REVA_LDAP_PORT"}, - Destination: &cfg.Reva.LDAP.Port, - }, - &cli.StringFlag{ - Name: "ldap-base-dn", - Value: "dc=example,dc=org", - Usage: "LDAP basedn", - EnvVars: []string{"REVA_LDAP_BASE_DN"}, - Destination: &cfg.Reva.LDAP.BaseDN, - }, - &cli.StringFlag{ - Name: "ldap-userfilter", - Value: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", - Usage: "LDAP filter used when getting a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.", - EnvVars: []string{"REVA_LDAP_USERFILTER"}, - Destination: &cfg.Reva.LDAP.UserFilter, - }, - &cli.StringFlag{ - Name: "ldap-attributefilter", - Value: "(&(objectclass=posixAccount)({{attr}}={{value}}))", - Usage: "LDAP filter used when searching for a user by claim/attribute. {{attr}} will be replaced with the attribute, {{value}} with the value.", - EnvVars: []string{"REVA_LDAP_ATTRIBUTEFILTER"}, - Destination: &cfg.Reva.LDAP.AttributeFilter, - }, - &cli.StringFlag{ - Name: "ldap-findfilter", - Value: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", - Usage: "LDAP filter used when searching for recipients. {{query}} will be replaced with the search query", - EnvVars: []string{"REVA_LDAP_FINDFILTER"}, - Destination: &cfg.Reva.LDAP.FindFilter, - }, - &cli.StringFlag{ - Name: "ldap-groupfilter", - // FIXME the reva implementation needs to use the memberof overlay to get the cn when it only has the uuid, - // because the ldap schema either uses the dn or the member(of) attributes to establish membership - Value: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))", // This filter will never work - Usage: "LDAP filter used when getting the groups of a user. The CS3 userid properties {{.OpaqueId}} and {{.Idp}} are available.", - EnvVars: []string{"REVA_LDAP_GROUPFILTER"}, - Destination: &cfg.Reva.LDAP.GroupFilter, - }, - &cli.StringFlag{ - Name: "ldap-bind-dn", - Value: "cn=reva,ou=sysusers,dc=example,dc=org", - Usage: "LDAP bind dn", - EnvVars: []string{"REVA_LDAP_BIND_DN"}, - Destination: &cfg.Reva.LDAP.BindDN, - }, - &cli.StringFlag{ - Name: "ldap-bind-password", - Value: "reva", - Usage: "LDAP bind password", - EnvVars: []string{"REVA_LDAP_BIND_PASSWORD"}, - Destination: &cfg.Reva.LDAP.BindPassword, - }, - &cli.StringFlag{ - Name: "ldap-idp", - Value: "https://localhost:9200", - Usage: "Identity provider to use for users", - EnvVars: []string{"REVA_LDAP_IDP"}, - Destination: &cfg.Reva.LDAP.IDP, - }, - // ldap dn is always the dn - &cli.StringFlag{ - Name: "ldap-schema-uid", - Value: "ownclouduuid", - Usage: "LDAP schema uid", - EnvVars: []string{"REVA_LDAP_SCHEMA_UID"}, - Destination: &cfg.Reva.LDAP.Schema.UID, - }, - &cli.StringFlag{ - Name: "ldap-schema-mail", - Value: "mail", - Usage: "LDAP schema mail", - EnvVars: []string{"REVA_LDAP_SCHEMA_MAIL"}, - Destination: &cfg.Reva.LDAP.Schema.Mail, - }, - &cli.StringFlag{ - Name: "ldap-schema-displayName", - Value: "displayname", - Usage: "LDAP schema displayName", - EnvVars: []string{"REVA_LDAP_SCHEMA_DISPLAYNAME"}, - Destination: &cfg.Reva.LDAP.Schema.DisplayName, - }, - &cli.StringFlag{ - Name: "ldap-schema-cn", - Value: "cn", - Usage: "LDAP schema cn", - EnvVars: []string{"REVA_LDAP_SCHEMA_CN"}, - Destination: &cfg.Reva.LDAP.Schema.CN, - }, - &cli.StringFlag{ - Name: "ldap-schema-uidnumber", - Value: "uidnumber", - Usage: "LDAP schema uidnumber", - EnvVars: []string{"REVA_LDAP_SCHEMA_UID_NUMBER"}, - Destination: &cfg.Reva.LDAP.Schema.UIDNumber, - }, - &cli.StringFlag{ - Name: "ldap-schema-gidnumber", - Value: "gidnumber", - Usage: "LDAP schema gidnumber", - EnvVars: []string{"REVA_LDAP_SCHEMA_GIDNUMBER"}, - Destination: &cfg.Reva.LDAP.Schema.GIDNumber, - }, &cli.StringFlag{ Name: "rest-client-id", Value: "", @@ -269,59 +144,12 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"REVA_REST_TARGET_API"}, Destination: &cfg.Reva.UserRest.TargetAPI, }, - - // Services - - // Users - - &cli.StringFlag{ - Name: "network", - Value: "tcp", - Usage: "Network to use for the reva service, can be 'tcp', 'udp' or 'unix'", - EnvVars: []string{"REVA_USERS_NETWORK"}, - Destination: &cfg.Reva.Users.Network, - }, - &cli.StringFlag{ - Name: "protocol", - Value: "grpc", - Usage: "protocol for reva service, can be 'http' or 'grpc'", - EnvVars: []string{"REVA_USERS_PROTOCOL"}, - Destination: &cfg.Reva.Users.Protocol, - }, - &cli.StringFlag{ - Name: "addr", - Value: "0.0.0.0:9144", - Usage: "Address to bind reva service", - EnvVars: []string{"REVA_USERS_ADDR"}, - Destination: &cfg.Reva.Users.Addr, - }, - &cli.StringFlag{ - Name: "url", - Value: "localhost:9144", - Usage: "URL to use for the reva service", - EnvVars: []string{"REVA_USERS_URL"}, - Destination: &cfg.Reva.Users.URL, - }, - &cli.StringSliceFlag{ - Name: "service", - Value: cli.NewStringSlice("userprovider"), // TODO preferences - Usage: "--service userprovider [--service otherservice]", - EnvVars: []string{"REVA_USERS_SERVICES"}, - }, - - &cli.StringFlag{ - Name: "driver", - Value: "ldap", - Usage: "user driver: 'demo', 'json', 'ldap', or 'rest'", - EnvVars: []string{"REVA_USERS_DRIVER"}, - Destination: &cfg.Reva.Users.Driver, - }, - &cli.StringFlag{ - Name: "json-config", - Value: "", - Usage: "Path to users.json file", - EnvVars: []string{"REVA_USERS_JSON"}, - Destination: &cfg.Reva.Users.JSON, - }, } + + flags = append(flags, TracingWithConfig(cfg)...) + flags = append(flags, DebugWithConfig(cfg)...) + flags = append(flags, SecretWithConfig(cfg)...) + flags = append(flags, LDAPWithConfig(cfg)...) + + return flags }