From 49f7266d6eda93445842dab2926402d71c6e7854 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 12 Mar 2021 16:45:23 +0100 Subject: [PATCH] add all storages to new config scheme --- storage/pkg/flagset/authbasic.go | 13 ++-- storage/pkg/flagset/authbearer.go | 19 +++--- storage/pkg/flagset/debug.go | 3 +- storage/pkg/flagset/drivereos.go | 20 ++++--- storage/pkg/flagset/driverlocal.go | 3 +- storage/pkg/flagset/driverocis.go | 7 ++- storage/pkg/flagset/driverowncloud.go | 15 ++--- storage/pkg/flagset/frontend.go | 35 +++++------ storage/pkg/flagset/gateway.go | 76 +++++++++++------------- storage/pkg/flagset/groups.go | 15 ++--- storage/pkg/flagset/health.go | 3 +- storage/pkg/flagset/ldap.go | 53 +++++++++-------- storage/pkg/flagset/rest.go | 19 +++--- storage/pkg/flagset/secret.go | 3 +- storage/pkg/flagset/sharing.go | 15 ++--- storage/pkg/flagset/sharingsql.go | 11 ++-- storage/pkg/flagset/storagehome.go | 33 +++++----- storage/pkg/flagset/storagepubliclink.go | 11 ++-- storage/pkg/flagset/storageusers.go | 29 ++++----- storage/pkg/flagset/tracing.go | 9 +-- storage/pkg/flagset/users.go | 15 ++--- 21 files changed, 212 insertions(+), 195 deletions(-) diff --git a/storage/pkg/flagset/authbasic.go b/storage/pkg/flagset/authbasic.go index 777764366..4f5ae182b 100644 --- a/storage/pkg/flagset/authbasic.go +++ b/storage/pkg/flagset/authbasic.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9147", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBasic.DebugAddr, "0.0.0.0:9147"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_AUTH_BASIC_DEBUG_ADDR"}, Destination: &cfg.Reva.AuthBasic.DebugAddr, @@ -22,14 +23,14 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "auth-driver", - Value: "ldap", + Value: flags.OverrideDefaultString(cfg.Reva.AuthProvider.Driver, "ldap"), Usage: "auth driver: 'demo', 'json' or 'ldap'", EnvVars: []string{"STORAGE_AUTH_DRIVER"}, Destination: &cfg.Reva.AuthProvider.Driver, }, &cli.StringFlag{ Name: "auth-json", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.AuthProvider.JSON, ""), Usage: "Path to users.json file", EnvVars: []string{"STORAGE_AUTH_JSON"}, Destination: &cfg.Reva.AuthProvider.JSON, @@ -41,14 +42,14 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBasic.GRPCNetwork, "tcp"), Usage: "Network to use for the storage auth-basic service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_AUTH_BASIC_GRPC_NETWORK"}, Destination: &cfg.Reva.AuthBasic.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9146", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBasic.GRPCAddr, "0.0.0.0:9146"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_AUTH_BASIC_GRPC_ADDR"}, Destination: &cfg.Reva.AuthBasic.GRPCAddr, @@ -64,7 +65,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-url", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "URL to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, diff --git a/storage/pkg/flagset/authbearer.go b/storage/pkg/flagset/authbearer.go index 2eba9559c..d822a9598 100644 --- a/storage/pkg/flagset/authbearer.go +++ b/storage/pkg/flagset/authbearer.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9149", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBearer.DebugAddr, "0.0.0.0:9149"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_AUTH_BEARER_DEBUG_ADDR"}, Destination: &cfg.Reva.AuthBearer.DebugAddr, @@ -22,14 +23,14 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "oidc-issuer", - Value: "https://localhost:9200", + Value: flags.OverrideDefaultString(cfg.Reva.OIDC.Issuer, "https://localhost:9200"), Usage: "OIDC issuer", EnvVars: []string{"STORAGE_OIDC_ISSUER", "OCIS_URL"}, // STORAGE_OIDC_ISSUER takes precedence over OCIS_URL Destination: &cfg.Reva.OIDC.Issuer, }, &cli.BoolFlag{ Name: "oidc-insecure", - Value: true, + Value: flags.OverrideDefaultBool(cfg.Reva.OIDC.Insecure, true), Usage: "OIDC allow insecure communication", EnvVars: []string{"STORAGE_OIDC_INSECURE"}, Destination: &cfg.Reva.OIDC.Insecure, @@ -42,21 +43,21 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { // AFAICT we want to use the account id from ocis-accounts // TODO add an ocis middleware to storage that changes the users opaqueid? // TODO add an ocis-accounts backed user manager - Value: "preferred_username", + Value: flags.OverrideDefaultString(cfg.Reva.OIDC.IDClaim, "preferred_username"), Usage: "OIDC id claim", EnvVars: []string{"STORAGE_OIDC_ID_CLAIM"}, Destination: &cfg.Reva.OIDC.IDClaim, }, &cli.StringFlag{ Name: "oidc-uid-claim", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.OIDC.UIDClaim, ""), Usage: "OIDC uid claim", EnvVars: []string{"STORAGE_OIDC_UID_CLAIM"}, Destination: &cfg.Reva.OIDC.UIDClaim, }, &cli.StringFlag{ Name: "oidc-gid-claim", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.OIDC.GIDClaim, ""), Usage: "OIDC gid claim", EnvVars: []string{"STORAGE_OIDC_GID_CLAIM"}, Destination: &cfg.Reva.OIDC.GIDClaim, @@ -68,14 +69,14 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBearer.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_AUTH_BEARER_GRPC_NETWORK"}, Destination: &cfg.Reva.AuthBearer.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9148", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBearer.GRPCAddr, "0.0.0.0:9148"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_AUTH_BEARER_GRPC_ADDR"}, Destination: &cfg.Reva.AuthBearer.GRPCAddr, @@ -91,7 +92,7 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-url", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "0.0.0.0:9142"), Usage: "URL to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, diff --git a/storage/pkg/flagset/debug.go b/storage/pkg/flagset/debug.go index b0cc5bd65..ce55ee3ba 100644 --- a/storage/pkg/flagset/debug.go +++ b/storage/pkg/flagset/debug.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,7 +11,7 @@ func DebugWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "debug-token", - Value: "", + Value: flags.OverrideDefaultString(cfg.Debug.Token, ""), Usage: "Token to grant metrics access", EnvVars: []string{"STORAGE_DEBUG_TOKEN"}, Destination: &cfg.Debug.Token, diff --git a/storage/pkg/flagset/drivereos.go b/storage/pkg/flagset/drivereos.go index 523e11c84..416a433ee 100644 --- a/storage/pkg/flagset/drivereos.go +++ b/storage/pkg/flagset/drivereos.go @@ -3,6 +3,8 @@ package flagset import ( "os" + "github.com/owncloud/ocis/ocis-pkg/flags" + "github.com/micro/cli/v2" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -13,7 +15,7 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-eos-namespace", - Value: "/eos/dockertest/reva", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.Root, "/eos/dockertest/reva"), Usage: "Namespace for metadata operations", EnvVars: []string{"STORAGE_DRIVER_EOS_NAMESPACE"}, Destination: &cfg.Reva.Storages.EOS.Root, @@ -27,42 +29,42 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "storage-eos-share-folder", - Value: "/Shares", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.ShareFolder, "/Shares"), Usage: "name of the share folder", EnvVars: []string{"STORAGE_DRIVER_EOS_SHARE_FOLDER"}, Destination: &cfg.Reva.Storages.EOS.ShareFolder, }, &cli.StringFlag{ Name: "storage-eos-binary", - Value: "/usr/bin/eos", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.EosBinary, "/usr/bin/eos"), Usage: "Location of the eos binary", EnvVars: []string{"STORAGE_DRIVER_EOS_BINARY"}, Destination: &cfg.Reva.Storages.EOS.EosBinary, }, &cli.StringFlag{ Name: "storage-eos-xrdcopy-binary", - Value: "/usr/bin/xrdcopy", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.XrdcopyBinary, "/usr/bin/xrdcopy"), Usage: "Location of the xrdcopy binary", EnvVars: []string{"STORAGE_DRIVER_EOS_XRDCOPY_BINARY"}, Destination: &cfg.Reva.Storages.EOS.XrdcopyBinary, }, &cli.StringFlag{ Name: "storage-eos-master-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.MasterURL, "root://eos-mgm1.eoscluster.cern.ch:1094"), Usage: "URL of the Master EOS MGM", EnvVars: []string{"STORAGE_DRIVER_EOS_MASTER_URL"}, Destination: &cfg.Reva.Storages.EOS.MasterURL, }, &cli.StringFlag{ Name: "storage-eos-slave-url", - Value: "root://eos-mgm1.eoscluster.cern.ch:1094", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.SlaveURL, "root://eos-mgm1.eoscluster.cern.ch:1094"), Usage: "URL of the Slave EOS MGM", EnvVars: []string{"STORAGE_DRIVER_EOS_SLAVE_URL"}, Destination: &cfg.Reva.Storages.EOS.SlaveURL, }, &cli.StringFlag{ Name: "storage-eos-cache-directory", - Value: os.TempDir(), + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.CacheDirectory, os.TempDir()), Usage: "Location on the local fs where to store reads", EnvVars: []string{"STORAGE_DRIVER_EOS_CACHE_DIRECTORY"}, Destination: &cfg.Reva.Storages.EOS.CacheDirectory, @@ -117,14 +119,14 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "storage-eos-layout", - Value: "{{substr 0 1 .Username}}/{{.Username}}", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.UserLayout, "{{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{"STORAGE_DRIVER_EOS_LAYOUT"}, Destination: &cfg.Reva.Storages.EOS.UserLayout, }, &cli.StringFlag{ Name: "storage-eos-gatewaysvc", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.EOS.GatewaySVC, "localhost:9142"), Usage: "URL to use for the storage gateway service", EnvVars: []string{"STORAGE_DRIVER_EOS_GATEWAYSVC"}, Destination: &cfg.Reva.Storages.EOS.GatewaySVC, diff --git a/storage/pkg/flagset/driverlocal.go b/storage/pkg/flagset/driverlocal.go index 6184fa2b3..256d117e9 100644 --- a/storage/pkg/flagset/driverlocal.go +++ b/storage/pkg/flagset/driverlocal.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,7 +11,7 @@ func DriverLocalWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "storage-local-root", - Value: "/var/tmp/ocis/storage/local", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.Local.Root, "/var/tmp/ocis/storage/local"), Usage: "the path to the local storage root", EnvVars: []string{"STORAGE_DRIVER_LOCAL_ROOT"}, Destination: &cfg.Reva.Storages.Local.Root, diff --git a/storage/pkg/flagset/driverocis.go b/storage/pkg/flagset/driverocis.go index 130065a52..dd323479b 100644 --- a/storage/pkg/flagset/driverocis.go +++ b/storage/pkg/flagset/driverocis.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,21 +11,21 @@ func DriverOCISWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "storage-ocis-root", - Value: "/var/tmp/ocis/storage/users", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.Local.Root, "/var/tmp/ocis/storage/users"), Usage: "the path to the local storage root", EnvVars: []string{"STORAGE_DRIVER_OCIS_ROOT"}, Destination: &cfg.Reva.Storages.Common.Root, }, &cli.BoolFlag{ Name: "storage-ocis-enable-home", - Value: false, + Value: flags.OverrideDefaultBool(cfg.Reva.Storages.Common.EnableHome, false), Usage: "enable the creation of home storages", EnvVars: []string{"STORAGE_DRIVER_OCIS_ENABLE_HOME"}, Destination: &cfg.Reva.Storages.Common.EnableHome, }, &cli.StringFlag{ Name: "storage-ocis-layout", - Value: "{{.Id.OpaqueId}}", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.Local.Root, "{{.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{"STORAGE_DRIVER_OCIS_LAYOUT"}, Destination: &cfg.Reva.Storages.Common.UserLayout, diff --git a/storage/pkg/flagset/driverowncloud.go b/storage/pkg/flagset/driverowncloud.go index 633c0b4df..65dfd183e 100644 --- a/storage/pkg/flagset/driverowncloud.go +++ b/storage/pkg/flagset/driverowncloud.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,49 +11,49 @@ func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "storage-owncloud-datadir", - Value: "/var/tmp/ocis/storage/owncloud", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.OwnCloud.Root, "/var/tmp/ocis/storage/owncloud"), Usage: "the path to the owncloud data directory", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_DATADIR"}, Destination: &cfg.Reva.Storages.OwnCloud.Root, }, &cli.StringFlag{ Name: "storage-owncloud-uploadinfo-dir", - Value: "/var/tmp/ocis/storage/uploadinfo", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.OwnCloud.UploadInfoDir, "/var/tmp/ocis/storage/uploadinfo"), Usage: "the path to the tus upload info directory", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_UPLOADINFO_DIR"}, Destination: &cfg.Reva.Storages.OwnCloud.UploadInfoDir, }, &cli.StringFlag{ Name: "storage-owncloud-share-folder", - Value: "/Shares", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.OwnCloud.ShareFolder, "/Shares"), Usage: "name of the shares folder", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_SHARE_FOLDER"}, Destination: &cfg.Reva.Storages.OwnCloud.ShareFolder, }, &cli.BoolFlag{ Name: "storage-owncloud-scan", - Value: true, + Value: flags.OverrideDefaultBool(cfg.Reva.Storages.OwnCloud.Scan, true), Usage: "scan files on startup to add fileids", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_SCAN"}, Destination: &cfg.Reva.Storages.OwnCloud.Scan, }, &cli.StringFlag{ Name: "storage-owncloud-redis", - Value: ":6379", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.OwnCloud.Redis, ":6379"), Usage: "the address of the redis server", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_REDIS_ADDR"}, Destination: &cfg.Reva.Storages.OwnCloud.Redis, }, &cli.BoolFlag{ Name: "storage-owncloud-enable-home", - Value: false, + Value: flags.OverrideDefaultBool(cfg.Reva.Storages.OwnCloud.EnableHome, false), Usage: "enable the creation of home storages", EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_ENABLE_HOME"}, Destination: &cfg.Reva.Storages.OwnCloud.EnableHome, }, &cli.StringFlag{ Name: "storage-owncloud-layout", - Value: "{{.Id.OpaqueId}}", + Value: flags.OverrideDefaultString(cfg.Reva.Storages.OwnCloud.UserLayout, "{{.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{"STORAGE_DRIVER_OWNCLOUD_LAYOUT"}, Destination: &cfg.Reva.Storages.OwnCloud.UserLayout, diff --git a/storage/pkg/flagset/frontend.go b/storage/pkg/flagset/frontend.go index 8684abb3f..3033ab30d 100644 --- a/storage/pkg/flagset/frontend.go +++ b/storage/pkg/flagset/frontend.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9141", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.DebugAddr, "0.0.0.0:9141"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_FRONTEND_DEBUG_ADDR"}, Destination: &cfg.Reva.Frontend.DebugAddr, @@ -22,7 +23,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "transfer-secret", - Value: "replace-me-with-a-transfer-secret", + Value: flags.OverrideDefaultString(cfg.Reva.TransferSecret, "replace-me-with-a-transfer-secret"), Usage: "Transfer secret for datagateway", EnvVars: []string{"STORAGE_TRANSFER_SECRET"}, Destination: &cfg.Reva.TransferSecret, @@ -32,14 +33,14 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "chunk-folder", - Value: "/var/tmp/ocis/tmp/chunks", + Value: flags.OverrideDefaultString(cfg.Reva.OCDav.WebdavNamespace, "/var/tmp/ocis/tmp/chunks"), Usage: "temp directory for chunked uploads", EnvVars: []string{"STORAGE_CHUNK_FOLDER"}, Destination: &cfg.Reva.OCDav.WebdavNamespace, }, &cli.StringFlag{ Name: "webdav-namespace", - Value: "/home/", + Value: flags.OverrideDefaultString(cfg.Reva.OCDav.WebdavNamespace, "/home/"), Usage: "Namespace prefix for the /webdav endpoint", EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"}, Destination: &cfg.Reva.OCDav.WebdavNamespace, @@ -49,7 +50,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { // this can eg. be set to /eos/users &cli.StringFlag{ Name: "dav-files-namespace", - Value: "/users/", + Value: flags.OverrideDefaultString(cfg.Reva.OCDav.DavFilesNamespace, "/users/"), Usage: "Namespace prefix for the webdav /dav/files endpoint", EnvVars: []string{"STORAGE_DAV_FILES_NAMESPACE"}, Destination: &cfg.Reva.OCDav.DavFilesNamespace, @@ -61,14 +62,14 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.HTTPNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_FRONTEND_HTTP_NETWORK"}, Destination: &cfg.Reva.Frontend.HTTPNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9140", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.HTTPAddr, "0.0.0.0:9140"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_FRONTEND_HTTP_ADDR"}, Destination: &cfg.Reva.Frontend.HTTPAddr, @@ -78,7 +79,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { // by both the gateway and frontend service &cli.StringFlag{ Name: "public-url", - Value: "https://localhost:9200", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.PublicURL, "https://localhost:9200"), Usage: "URL to use for the storage service", EnvVars: []string{"STORAGE_FRONTEND_PUBLIC_URL", "OCIS_URL"}, // STORAGE_FRONTEND_PUBLIC_URL takes precedence over OCIS_URL Destination: &cfg.Reva.Frontend.PublicURL, @@ -91,28 +92,28 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "datagateway-prefix", - Value: "data", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.DatagatewayPrefix, "data"), Usage: "datagateway prefix", EnvVars: []string{"STORAGE_FRONTEND_DATAGATEWAY_PREFIX"}, Destination: &cfg.Reva.Frontend.DatagatewayPrefix, }, &cli.StringFlag{ Name: "ocdav-prefix", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.OCDavPrefix, ""), Usage: "owncloud webdav endpoint prefix", EnvVars: []string{"STORAGE_FRONTEND_OCDAV_PREFIX"}, Destination: &cfg.Reva.Frontend.OCDavPrefix, }, &cli.StringFlag{ Name: "ocs-prefix", - Value: "ocs", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.OCSPrefix, "ocs"), Usage: "open collaboration services endpoint prefix", EnvVars: []string{"STORAGE_FRONTEND_OCS_PREFIX"}, Destination: &cfg.Reva.Frontend.OCSPrefix, }, &cli.StringFlag{ Name: "ocs-share-prefix", - Value: "/Shares", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.OCSSharePrefix, "/shares"), Usage: "the prefix prepended to the path of shared files", EnvVars: []string{"STORAGE_FRONTEND_OCS_Share_PREFIX"}, Destination: &cfg.Reva.Frontend.OCSSharePrefix, @@ -121,7 +122,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-url", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "URL to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, @@ -130,21 +131,21 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { // Chunking &cli.StringFlag{ Name: "default-upload-protocol", - Value: "tus", + Value: flags.OverrideDefaultString(cfg.Reva.DefaultUploadProtocol, "tus"), Usage: "Default upload chunking protocol to be used out of tus/v1/ng", EnvVars: []string{"STORAGE_FRONTEND_DEFAULT_UPLOAD_PROTOCOL"}, Destination: &cfg.Reva.DefaultUploadProtocol, }, &cli.IntFlag{ Name: "upload-max-chunk-size", - Value: 0, + Value: flags.OverrideDefaultInt(cfg.Reva.UploadMaxChunkSize, 0), Usage: "Max chunk size in bytes to advertise to clients through capabilities, or 0 for unlimited", EnvVars: []string{"STORAGE_FRONTEND_UPLOAD_MAX_CHUNK_SIZE"}, Destination: &cfg.Reva.UploadMaxChunkSize, }, &cli.StringFlag{ Name: "upload-http-method-override", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UploadHTTPMethodOverride, ""), Usage: "Specify an HTTP method (ex: POST) that clients should to use when uploading instead of PATCH", EnvVars: []string{"STORAGE_FRONTEND_UPLOAD_HTTP_METHOD_OVERRIDE"}, Destination: &cfg.Reva.UploadHTTPMethodOverride, @@ -157,7 +158,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "checksum-preferred-upload-type", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.ChecksumPreferredUploadType, ""), Usage: "Specify the preferred checksum algorithm used for uploads", EnvVars: []string{"STORAGE_FRONTEND_CHECKSUM_PREFERRED_UPLOAD_TYPE"}, Destination: &cfg.Reva.ChecksumPreferredUploadType, diff --git a/storage/pkg/flagset/gateway.go b/storage/pkg/flagset/gateway.go index 179e95eba..6211948a4 100644 --- a/storage/pkg/flagset/gateway.go +++ b/storage/pkg/flagset/gateway.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9143", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.DebugAddr, "0.0.0.0:9143"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_GATEWAY_DEBUG_ADDR"}, Destination: &cfg.Reva.Gateway.DebugAddr, @@ -22,42 +23,39 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "transfer-secret", - Value: "replace-me-with-a-transfer-secret", + Value: flags.OverrideDefaultString(cfg.Reva.TransferSecret, "replace-me-with-a-transfer-secret"), Usage: "Transfer secret for datagateway", EnvVars: []string{"STORAGE_TRANSFER_SECRET"}, Destination: &cfg.Reva.TransferSecret, }, &cli.IntFlag{ Name: "transfer-expires", - Value: 24 * 60 * 60, // one day + Value: flags.OverrideDefaultInt(cfg.Reva.TransferExpires, 24*60*60), // one day Usage: "Transfer token ttl in seconds", EnvVars: []string{"STORAGE_TRANSFER_EXPIRES"}, Destination: &cfg.Reva.TransferExpires, }, - // TODO allow configuring clients - // Services // Gateway - &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_GATEWAY_GRPC_NETWORK"}, Destination: &cfg.Reva.Gateway.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.GRPCAddr, "0.0.0.0:9142"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_GATEWAY_GRPC_ADDR"}, Destination: &cfg.Reva.Gateway.GRPCAddr, }, &cli.StringFlag{ Name: "endpoint", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "endpoint to use for the storage service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, @@ -69,24 +67,22 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"STORAGE_GATEWAY_SERVICES"}, }, &cli.BoolFlag{ - Name: "commit-share-to-storage-grant", - Value: true, - // TODO clarify + Name: "commit-share-to-storage-grant", + Value: flags.OverrideDefaultBool(cfg.Reva.Gateway.CommitShareToStorageGrant, true), Usage: "Commit shares to the share manager", EnvVars: []string{"STORAGE_GATEWAY_COMMIT_SHARE_TO_STORAGE_GRANT"}, Destination: &cfg.Reva.Gateway.CommitShareToStorageGrant, }, &cli.BoolFlag{ - Name: "commit-share-to-storage-ref", - Value: true, - // TODO clarify + Name: "commit-share-to-storage-ref", + Value: flags.OverrideDefaultBool(cfg.Reva.Gateway.CommitShareToStorageRef, true), Usage: "Commit shares to the storage", EnvVars: []string{"STORAGE_GATEWAY_COMMIT_SHARE_TO_STORAGE_REF"}, Destination: &cfg.Reva.Gateway.CommitShareToStorageRef, }, &cli.StringFlag{ Name: "share-folder", - Value: "Shares", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.ShareFolder, "Shares"), Usage: "mount shares in this folder of the home storage provider", EnvVars: []string{"STORAGE_GATEWAY_SHARE_FOLDER"}, Destination: &cfg.Reva.Gateway.ShareFolder, @@ -99,14 +95,14 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "storage-home-mapping", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.HomeMapping, ""), Usage: "mapping template for user home paths to user-specific mount points, e.g. /home/{{substr 0 1 .Username}}", EnvVars: []string{"STORAGE_GATEWAY_HOME_MAPPING"}, Destination: &cfg.Reva.Gateway.HomeMapping, }, &cli.IntFlag{ Name: "etag-cache-ttl", - Value: 0, + Value: flags.OverrideDefaultInt(cfg.Reva.Gateway.EtagCacheTTL, 0), Usage: "TTL for the home and shares directory etags cache", EnvVars: []string{"STORAGE_GATEWAY_ETAG_CACHE_TTL"}, Destination: &cfg.Reva.Gateway.EtagCacheTTL, @@ -116,14 +112,14 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "auth-basic-endpoint", - Value: "localhost:9146", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBasic.Endpoint, "localhost:9146"), Usage: "endpoint to use for the basic auth provider", EnvVars: []string{"STORAGE_AUTH_BASIC_ENDPOINT"}, Destination: &cfg.Reva.AuthBasic.Endpoint, }, &cli.StringFlag{ Name: "auth-bearer-endpoint", - Value: "localhost:9148", + Value: flags.OverrideDefaultString(cfg.Reva.AuthBearer.Endpoint, "localhost:9148"), Usage: "endpoint to use for the bearer auth provider", EnvVars: []string{"STORAGE_AUTH_BEARER_ENDPOINT"}, Destination: &cfg.Reva.AuthBearer.Endpoint, @@ -133,7 +129,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-registry-driver", - Value: "static", + Value: flags.OverrideDefaultString(cfg.Reva.StorageRegistry.Driver, "static"), Usage: "driver of the storage registry", EnvVars: []string{"STORAGE_STORAGE_REGISTRY_DRIVER"}, Destination: &cfg.Reva.StorageRegistry.Driver, @@ -147,7 +143,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-home-provider", - Value: "/home", + Value: flags.OverrideDefaultString(cfg.Reva.StorageRegistry.HomeProvider, "/home"), Usage: "mount point of the storage provider for user homes in the global namespace", EnvVars: []string{"STORAGE_REGISTRY_HOME_PROVIDER"}, Destination: &cfg.Reva.StorageRegistry.HomeProvider, @@ -158,35 +154,35 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { // by both the gateway and frontend service &cli.StringFlag{ Name: "public-url", - Value: "https://localhost:9200", + Value: flags.OverrideDefaultString(cfg.Reva.Frontend.PublicURL, "https://localhost:9200"), Usage: "URL to use for the storage service", EnvVars: []string{"STORAGE_FRONTEND_PUBLIC_URL", "OCIS_URL"}, // STORAGE_FRONTEND_PUBLIC_URL takes precedence over OCIS_URL Destination: &cfg.Reva.Frontend.PublicURL, }, &cli.StringFlag{ Name: "datagateway-url", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.DataGateway.PublicURL, ""), Usage: "URL to use for the storage datagateway, defaults to /data", EnvVars: []string{"STORAGE_DATAGATEWAY_PUBLIC_URL"}, Destination: &cfg.Reva.DataGateway.PublicURL, }, &cli.StringFlag{ Name: "userprovider-endpoint", - Value: "localhost:9144", + Value: flags.OverrideDefaultString(cfg.Reva.Users.Endpoint, "localhost:9144"), Usage: "endpoint to use for the userprovider", EnvVars: []string{"STORAGE_USERPROVIDER_ENDPOINT"}, Destination: &cfg.Reva.Users.Endpoint, }, &cli.StringFlag{ - Name: "groupprovider-endpoint", - Value: "localhost:9160", - Usage: "endpoint to use for the groupprovider", - EnvVars: []string{"STORAGE_GROUPPROVIDER_ENDPOINT"}, - Destination: &cfg.Reva.Groups.Endpoint, - }, + Name: "groupprovider-endpoint", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.Endpoint, "localhost:9160"), + Usage: "endpoint to use for the groupprovider", + EnvVars: []string{"STORAGE_GROUPPROVIDER_ENDPOINT"}, + Destination: &cfg.Reva.Groups.Endpoint, + }, &cli.StringFlag{ Name: "sharing-endpoint", - Value: "localhost:9150", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.Endpoint, "localhost:9150"), Usage: "endpoint to use for the storage service", EnvVars: []string{"STORAGE_SHARING_ENDPOINT"}, Destination: &cfg.Reva.Sharing.Endpoint, @@ -196,21 +192,21 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-home-endpoint", - Value: "localhost:9154", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.Endpoint, "localhost:9154"), Usage: "endpoint to use for the home storage", EnvVars: []string{"STORAGE_HOME_ENDPOINT"}, Destination: &cfg.Reva.StorageHome.Endpoint, }, &cli.StringFlag{ Name: "storage-home-mount-path", - Value: "/home", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.MountPath, "/home"), Usage: "mount path", EnvVars: []string{"STORAGE_HOME_MOUNT_PATH"}, Destination: &cfg.Reva.StorageHome.MountPath, }, &cli.StringFlag{ Name: "storage-home-mount-id", - Value: "1284d238-aa92-42ce-bdc4-0b0000009154", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.MountID, "1284d238-aa92-42ce-bdc4-0b0000009154"), Usage: "mount id", EnvVars: []string{"STORAGE_HOME_MOUNT_ID"}, Destination: &cfg.Reva.StorageHome.MountID, @@ -220,21 +216,21 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "storage-users-endpoint", - Value: "localhost:9157", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.Endpoint, "localhost:9157"), Usage: "endpoint to use for the users storage", EnvVars: []string{"STORAGE_USERS_ENDPOINT"}, Destination: &cfg.Reva.StorageUsers.Endpoint, }, &cli.StringFlag{ Name: "storage-users-mount-path", - Value: "/users", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.MountPath, "/users"), Usage: "mount path", EnvVars: []string{"STORAGE_USERS_MOUNT_PATH"}, Destination: &cfg.Reva.StorageUsers.MountPath, }, &cli.StringFlag{ Name: "storage-users-mount-id", - Value: "1284d238-aa92-42ce-bdc4-0b0000009157", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.MountID, "1284d238-aa92-42ce-bdc4-0b0000009157"), Usage: "mount id", EnvVars: []string{"STORAGE_USERS_MOUNT_ID"}, Destination: &cfg.Reva.StorageUsers.MountID, @@ -244,14 +240,14 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "public-link-endpoint", - Value: "localhost:9178", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.Endpoint, "localhost:9178"), Usage: "endpoint to use for the public links service", EnvVars: []string{"STORAGE_PUBLIC_LINK_ENDPOINT"}, Destination: &cfg.Reva.StoragePublicLink.Endpoint, }, &cli.StringFlag{ Name: "storage-public-link-mount-path", - Value: "/public", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.MountPath, "/public"), Usage: "mount path", EnvVars: []string{"STORAGE_PUBLIC_LINK_MOUNT_PATH"}, Destination: &cfg.Reva.StoragePublicLink.MountPath, diff --git a/storage/pkg/flagset/groups.go b/storage/pkg/flagset/groups.go index e472a068e..a55be77c1 100644 --- a/storage/pkg/flagset/groups.go +++ b/storage/pkg/flagset/groups.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9161", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.DebugAddr, "0.0.0.0:9161"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_GROUPPROVIDER_DEBUG_ADDR"}, Destination: &cfg.Reva.Groups.DebugAddr, @@ -24,21 +25,21 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_GROUPPROVIDER_NETWORK"}, Destination: &cfg.Reva.Groups.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9160", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.GRPCAddr, "0.0.0.0:9160"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_GROUPPROVIDER_ADDR"}, Destination: &cfg.Reva.Groups.GRPCAddr, }, &cli.StringFlag{ Name: "endpoint", - Value: "localhost:9160", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.Endpoint, "0.0.0.0:9160"), Usage: "URL to use for the storage service", EnvVars: []string{"STORAGE_GROUPPROVIDER_ENDPOINT"}, Destination: &cfg.Reva.Groups.Endpoint, @@ -52,21 +53,21 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "driver", - Value: "ldap", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.Driver, "ldap"), Usage: "group driver: 'json', 'ldap', or 'rest'", EnvVars: []string{"STORAGE_GROUPPROVIDER_DRIVER"}, Destination: &cfg.Reva.Groups.Driver, }, &cli.StringFlag{ Name: "json-config", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Groups.JSON, ""), Usage: "Path to groups.json file", EnvVars: []string{"STORAGE_GROUPPROVIDER_JSON"}, Destination: &cfg.Reva.Groups.JSON, }, &cli.IntFlag{ Name: "group-members-cache-expiration", - Value: 5, + Value: flags.OverrideDefaultInt(cfg.Reva.Groups.GroupMembersCacheExpiration, 5), Usage: "Time in minutes for redis cache expiration.", EnvVars: []string{"STORAGE_GROUP_CACHE_EXPIRATION"}, Destination: &cfg.Reva.Groups.GroupMembersCacheExpiration, diff --git a/storage/pkg/flagset/health.go b/storage/pkg/flagset/health.go index 381f35670..b3ed0a407 100644 --- a/storage/pkg/flagset/health.go +++ b/storage/pkg/flagset/health.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,7 +11,7 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9109", + Value: flags.OverrideDefaultString(cfg.Debug.Addr, "0.0.0.0:9109"), Usage: "Address to debug endpoint", EnvVars: []string{"STORAGE_DEBUG_ADDR"}, Destination: &cfg.Debug.Addr, diff --git a/storage/pkg/flagset/ldap.go b/storage/pkg/flagset/ldap.go index 73bd0c886..b5f069a45 100644 --- a/storage/pkg/flagset/ldap.go +++ b/storage/pkg/flagset/ldap.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,28 +11,28 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "ldap-hostname", - Value: "localhost", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.Hostname, "localhost"), Usage: "LDAP hostname", EnvVars: []string{"STORAGE_LDAP_HOSTNAME"}, Destination: &cfg.Reva.LDAP.Hostname, }, &cli.IntFlag{ Name: "ldap-port", - Value: 9126, + Value: flags.OverrideDefaultInt(cfg.Reva.LDAP.Port, 9126), Usage: "LDAP port", EnvVars: []string{"STORAGE_LDAP_PORT"}, Destination: &cfg.Reva.LDAP.Port, }, &cli.StringFlag{ Name: "ldap-base-dn", - Value: "dc=example,dc=org", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.BaseDN, "dc=example,dc=org"), Usage: "LDAP basedn", EnvVars: []string{"STORAGE_LDAP_BASE_DN"}, Destination: &cfg.Reva.LDAP.BaseDN, }, &cli.StringFlag{ Name: "ldap-loginfilter", - Value: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.LoginFilter, "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))"), Usage: "LDAP login filter", EnvVars: []string{"STORAGE_LDAP_LOGINFILTER"}, Destination: &cfg.Reva.LDAP.LoginFilter, @@ -41,21 +42,21 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "ldap-userfilter", - Value: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserFilter, "(&(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{"STORAGE_LDAP_USERFILTER"}, Destination: &cfg.Reva.LDAP.UserFilter, }, &cli.StringFlag{ Name: "ldap-userattributefilter", - Value: "(&(objectclass=posixAccount)({{attr}}={{value}}))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserAttributeFilter, "(&(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{"STORAGE_LDAP_USERATTRIBUTEFILTER"}, Destination: &cfg.Reva.LDAP.UserAttributeFilter, }, &cli.StringFlag{ Name: "ldap-userfindfilter", - Value: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserFindFilter, "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"), Usage: "LDAP filter used when searching for user recipients. {{query}} will be replaced with the search query", EnvVars: []string{"STORAGE_LDAP_USERFINDFILTER"}, Destination: &cfg.Reva.LDAP.UserFindFilter, @@ -64,7 +65,7 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { Name: "ldap-usergroupfilter", // FIXME the storage 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 + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserGroupFilter, "(&(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{"STORAGE_LDAP_USERGROUPFILTER"}, Destination: &cfg.Reva.LDAP.UserGroupFilter, @@ -75,21 +76,21 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "ldap-groupfilter", - Value: "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupFilter, "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))"), Usage: "LDAP filter used when getting a group. The CS3 groupid properties {{.OpaqueId}} and {{.Idp}} are available.", EnvVars: []string{"STORAGE_LDAP_GROUPFILTER"}, Destination: &cfg.Reva.LDAP.GroupFilter, }, &cli.StringFlag{ Name: "ldap-groupattributefilter", - Value: "(&(objectclass=posixGroup)({{attr}}={{value}}))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupAttributeFilter, "(&(objectclass=posixGroup)({{attr}}={{value}}))"), Usage: "LDAP filter used when searching for a group by claim/attribute. {{attr}} will be replaced with the attribute, {{value}} with the value.", EnvVars: []string{"STORAGE_LDAP_GROUPATTRIBUTEFILTER"}, Destination: &cfg.Reva.LDAP.GroupAttributeFilter, }, &cli.StringFlag{ Name: "ldap-groupfindfilter", - Value: "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupFindFilter, "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))"), Usage: "LDAP filter used when searching for group recipients. {{query}} will be replaced with the search query", EnvVars: []string{"STORAGE_LDAP_GROUPFINDFILTER"}, Destination: &cfg.Reva.LDAP.GroupFindFilter, @@ -97,28 +98,28 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "ldap-groupmemberfilter", // FIXME the storage implementation needs to use the members overlay to get the cn when it only has the uuid - Value: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))", // This filter will never work + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupMemberFilter, "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))"), // This filter will never work Usage: "LDAP filter used when getting the members of a group. The CS3 groupid properties {{.OpaqueId}} and {{.Idp}} are available.", EnvVars: []string{"STORAGE_LDAP_GROUPMEMBERFILTER"}, Destination: &cfg.Reva.LDAP.GroupMemberFilter, }, &cli.StringFlag{ Name: "ldap-bind-dn", - Value: "cn=reva,ou=sysusers,dc=example,dc=org", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.BindDN, "cn=reva,ou=sysusers,dc=example,dc=org"), Usage: "LDAP bind dn", EnvVars: []string{"STORAGE_LDAP_BIND_DN"}, Destination: &cfg.Reva.LDAP.BindDN, }, &cli.StringFlag{ Name: "ldap-bind-password", - Value: "reva", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.BindPassword, "reva"), Usage: "LDAP bind password", EnvVars: []string{"STORAGE_LDAP_BIND_PASSWORD"}, Destination: &cfg.Reva.LDAP.BindPassword, }, &cli.StringFlag{ Name: "ldap-idp", - Value: "https://localhost:9200", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.IDP, "https://localhost:9200"), Usage: "Identity provider to use for users", EnvVars: []string{"STORAGE_LDAP_IDP", "OCIS_URL"}, // STORAGE_LDAP_IDP takes precedence over OCIS_URL Destination: &cfg.Reva.LDAP.IDP, @@ -129,42 +130,42 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "ldap-user-schema-uid", - Value: "ownclouduuid", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.UID, "ownclouduuid"), Usage: "LDAP user schema uid", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_UID"}, Destination: &cfg.Reva.LDAP.UserSchema.UID, }, &cli.StringFlag{ Name: "ldap-user-schema-mail", - Value: "mail", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.Mail, "mail"), Usage: "LDAP user schema mail", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_MAIL"}, Destination: &cfg.Reva.LDAP.UserSchema.Mail, }, &cli.StringFlag{ Name: "ldap-user-schema-displayName", - Value: "displayname", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.DisplayName, "displayname"), Usage: "LDAP user schema displayName", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_DISPLAYNAME"}, Destination: &cfg.Reva.LDAP.UserSchema.DisplayName, }, &cli.StringFlag{ Name: "ldap-user-schema-cn", - Value: "cn", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.CN, "cn"), Usage: "LDAP user schema cn", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_CN"}, Destination: &cfg.Reva.LDAP.UserSchema.CN, }, &cli.StringFlag{ Name: "ldap-user-schema-uidnumber", - Value: "uidnumber", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.UIDNumber, "uidnumber"), Usage: "LDAP user schema uidnumber", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_UID_NUMBER"}, Destination: &cfg.Reva.LDAP.UserSchema.UIDNumber, }, &cli.StringFlag{ Name: "ldap-user-schema-gidnumber", - Value: "gidnumber", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.UserSchema.GIDNumber, "gidnumber"), Usage: "LDAP user schema gidnumber", EnvVars: []string{"STORAGE_LDAP_USER_SCHEMA_GID_NUMBER"}, Destination: &cfg.Reva.LDAP.UserSchema.GIDNumber, @@ -174,35 +175,35 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "ldap-group-schema-gid", - Value: "cn", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupSchema.GID, "cn"), Usage: "LDAP group schema gid", EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_GID"}, Destination: &cfg.Reva.LDAP.GroupSchema.GID, }, &cli.StringFlag{ Name: "ldap-group-schema-mail", - Value: "mail", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupSchema.Mail, "mail"), Usage: "LDAP group schema mail", EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_MAIL"}, Destination: &cfg.Reva.LDAP.GroupSchema.Mail, }, &cli.StringFlag{ Name: "ldap-group-schema-displayName", - Value: "cn", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupSchema.DisplayName, "cn"), Usage: "LDAP group schema displayName", EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_DISPLAYNAME"}, Destination: &cfg.Reva.LDAP.GroupSchema.DisplayName, }, &cli.StringFlag{ Name: "ldap-group-schema-cn", - Value: "cn", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupSchema.CN, "cn"), Usage: "LDAP group schema cn", EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_CN"}, Destination: &cfg.Reva.LDAP.GroupSchema.CN, }, &cli.StringFlag{ Name: "ldap-group-schema-gidnumber", - Value: "gidnumber", + Value: flags.OverrideDefaultString(cfg.Reva.LDAP.GroupSchema.GIDNumber, "gidnumber"), Usage: "LDAP group schema gidnumber", EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_GID_NUMBER"}, Destination: &cfg.Reva.LDAP.GroupSchema.GIDNumber, diff --git a/storage/pkg/flagset/rest.go b/storage/pkg/flagset/rest.go index 2e733596f..34980637e 100644 --- a/storage/pkg/flagset/rest.go +++ b/storage/pkg/flagset/rest.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,63 +11,63 @@ func RestWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "rest-client-id", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.ClientID, ""), Usage: "User/group rest driver Client ID", EnvVars: []string{"STORAGE_REST_CLIENT_ID"}, Destination: &cfg.Reva.UserGroupRest.ClientID, }, &cli.StringFlag{ Name: "rest-client-secret", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.ClientSecret, ""), Usage: "User/group rest driver Client Secret", EnvVars: []string{"STORAGE_REST_CLIENT_SECRET"}, Destination: &cfg.Reva.UserGroupRest.ClientSecret, }, &cli.StringFlag{ Name: "rest-redis-address", - Value: "localhost:6379", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.RedisAddress, "localhost:6379"), Usage: "Address for redis server", EnvVars: []string{"STORAGE_REST_REDIS_ADDRESS"}, Destination: &cfg.Reva.UserGroupRest.RedisAddress, }, &cli.StringFlag{ Name: "rest-redis-username", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.RedisUsername, ""), Usage: "Username for redis server", EnvVars: []string{"STORAGE_REST_REDIS_USERNAME"}, Destination: &cfg.Reva.UserGroupRest.RedisUsername, }, &cli.StringFlag{ Name: "rest-redis-password", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.RedisPassword, ""), Usage: "Password for redis server", EnvVars: []string{"STORAGE_REST_REDIS_PASSWORD"}, Destination: &cfg.Reva.UserGroupRest.RedisPassword, }, &cli.StringFlag{ Name: "rest-id-provider", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.IDProvider, ""), Usage: "The OIDC Provider", EnvVars: []string{"STORAGE_REST_ID_PROVIDER"}, Destination: &cfg.Reva.UserGroupRest.IDProvider, }, &cli.StringFlag{ Name: "rest-api-base-url", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.APIBaseURL, ""), Usage: "Base API Endpoint", EnvVars: []string{"STORAGE_REST_API_BASE_URL"}, Destination: &cfg.Reva.UserGroupRest.APIBaseURL, }, &cli.StringFlag{ Name: "rest-oidc-token-endpoint", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.OIDCTokenEndpoint, ""), Usage: "Endpoint to generate token to access the API", EnvVars: []string{"STORAGE_REST_OIDC_TOKEN_ENDPOINT"}, Destination: &cfg.Reva.UserGroupRest.OIDCTokenEndpoint, }, &cli.StringFlag{ Name: "rest-target-api", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.UserGroupRest.TargetAPI, ""), Usage: "The target application", EnvVars: []string{"STORAGE_REST_TARGET_API"}, Destination: &cfg.Reva.UserGroupRest.TargetAPI, diff --git a/storage/pkg/flagset/secret.go b/storage/pkg/flagset/secret.go index d7004e481..cfb60555f 100644 --- a/storage/pkg/flagset/secret.go +++ b/storage/pkg/flagset/secret.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,7 +11,7 @@ func SecretWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "jwt-secret", - Value: "Pive-Fumkiu4", + Value: flags.OverrideDefaultString(cfg.Reva.JWTSecret, "Pive-Fumkiu4"), Usage: "Shared jwt secret for reva service communication", EnvVars: []string{"STORAGE_JWT_SECRET", "OCIS_JWT_SECRET"}, Destination: &cfg.Reva.JWTSecret, diff --git a/storage/pkg/flagset/sharing.go b/storage/pkg/flagset/sharing.go index 2926170c1..d32d1e651 100644 --- a/storage/pkg/flagset/sharing.go +++ b/storage/pkg/flagset/sharing.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9151", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.DebugAddr, "0.0.0.0:9151"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_SHARING_DEBUG_ADDR"}, Destination: &cfg.Reva.Sharing.DebugAddr, @@ -24,14 +25,14 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_SHARING_GRPC_NETWORK"}, Destination: &cfg.Reva.Sharing.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9150", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.GRPCAddr, "0.0.0.0:9150"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_SHARING_GRPC_ADDR"}, Destination: &cfg.Reva.Sharing.GRPCAddr, @@ -44,28 +45,28 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "user-driver", - Value: "json", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserDriver, "json"), Usage: "driver to use for the UserShareProvider", EnvVars: []string{"STORAGE_SHARING_USER_DRIVER"}, Destination: &cfg.Reva.Sharing.UserDriver, }, &cli.StringFlag{ Name: "user-json-file", - Value: "/var/tmp/ocis/storage/shares.json", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserJSONFile, "/var/tmp/ocis/storage/shares.json"), Usage: "file used to persist shares for the UserShareProvider", EnvVars: []string{"STORAGE_SHARING_USER_JSON_FILE"}, Destination: &cfg.Reva.Sharing.UserJSONFile, }, &cli.StringFlag{ Name: "public-driver", - Value: "json", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.PublicDriver, "json"), Usage: "driver to use for the PublicShareProvider", EnvVars: []string{"STORAGE_SHARING_PUBLIC_DRIVER"}, Destination: &cfg.Reva.Sharing.PublicDriver, }, &cli.StringFlag{ Name: "public-json-file", - Value: "/var/tmp/ocis/storage/publicshares.json", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.PublicJSONFile, "/var/tmp/ocis/storage/publicshares.json"), Usage: "file used to persist shares for the PublicShareProvider", EnvVars: []string{"STORAGE_SHARING_PUBLIC_JSON_FILE"}, Destination: &cfg.Reva.Sharing.PublicJSONFile, diff --git a/storage/pkg/flagset/sharingsql.go b/storage/pkg/flagset/sharingsql.go index 7bbeeeabd..5aef7ef77 100644 --- a/storage/pkg/flagset/sharingsql.go +++ b/storage/pkg/flagset/sharingsql.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -10,35 +11,35 @@ func SharingSQLWithConfig(cfg *config.Config) []cli.Flag { return []cli.Flag{ &cli.StringFlag{ Name: "user-sql-username", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserSQLUsername, ""), Usage: "Username to be used to connect to the SQL database", EnvVars: []string{"STORAGE_SHARING_USER_SQL_USERNAME"}, Destination: &cfg.Reva.Sharing.UserSQLUsername, }, &cli.StringFlag{ Name: "user-sql-password", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserSQLPassword, ""), Usage: "Password to be used to connect to the SQL database", EnvVars: []string{"STORAGE_SHARING_USER_SQL_PASSWORD"}, Destination: &cfg.Reva.Sharing.UserSQLPassword, }, &cli.StringFlag{ Name: "user-sql-host", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserSQLHost, ""), Usage: "Hostname of the SQL database", EnvVars: []string{"STORAGE_SHARING_USER_SQL_HOST"}, Destination: &cfg.Reva.Sharing.UserSQLHost, }, &cli.IntFlag{ Name: "user-sql-port", - Value: 1433, + Value: flags.OverrideDefaultInt(cfg.Reva.Sharing.UserSQLPort, 1433), Usage: "The port on which the SQL database is exposed", EnvVars: []string{"STORAGE_SHARING_USER_SQL_PORT"}, Destination: &cfg.Reva.Sharing.UserSQLPort, }, &cli.StringFlag{ Name: "user-sql-name", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Sharing.UserSQLName, ""), Usage: "Name of the SQL database", EnvVars: []string{"STORAGE_SHARING_USER_SQL_Name"}, Destination: &cfg.Reva.Sharing.UserSQLName, diff --git a/storage/pkg/flagset/storagehome.go b/storage/pkg/flagset/storagehome.go index b6c0fe9fc..090366a9c 100644 --- a/storage/pkg/flagset/storagehome.go +++ b/storage/pkg/flagset/storagehome.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9156", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.DebugAddr, "0.0.0.0:9156"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_HOME_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageHome.DebugAddr, @@ -24,28 +25,28 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "grpc-network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_HOME_GRPC_NETWORK"}, Destination: &cfg.Reva.StorageHome.GRPCNetwork, }, &cli.StringFlag{ Name: "grpc-addr", - Value: "0.0.0.0:9154", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.GRPCAddr, "0.0.0.0:9154"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_HOME_GRPC_ADDR"}, Destination: &cfg.Reva.StorageHome.GRPCAddr, }, &cli.StringFlag{ Name: "http-network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.HTTPNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_HOME_HTTP_NETWORK"}, Destination: &cfg.Reva.StorageHome.HTTPNetwork, }, &cli.StringFlag{ Name: "http-addr", - Value: "0.0.0.0:9155", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.HTTPAddr, "0.0.0.0:9155"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_HOME_HTTP_ADDR"}, Destination: &cfg.Reva.StorageHome.HTTPAddr, @@ -69,14 +70,14 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "driver", - Value: "ocis", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.Driver, "ocis"), Usage: "storage driver for home mount: eg. local, eos, owncloud, ocis or s3", EnvVars: []string{"STORAGE_HOME_DRIVER"}, Destination: &cfg.Reva.StorageHome.Driver, }, &cli.StringFlag{ Name: "mount-path", - Value: "/home", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.MountPath, "/home"), Usage: "mount path", EnvVars: []string{"STORAGE_HOME_MOUNT_PATH"}, Destination: &cfg.Reva.StorageHome.MountPath, @@ -84,43 +85,43 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "mount-id", // This is the mount id of the storage provider using the same storage driver - // as /home but withoud home enabled. - Value: "1284d238-aa92-42ce-bdc4-0b0000009157", // /users + // as /home but without home enabled. + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.MountID, "1284d238-aa92-42ce-bdc4-0b0000009157"), Usage: "mount id", EnvVars: []string{"STORAGE_HOME_MOUNT_ID"}, Destination: &cfg.Reva.StorageHome.MountID, }, &cli.BoolFlag{ Name: "expose-data-server", - Value: false, + Value: flags.OverrideDefaultBool(cfg.Reva.StorageHome.ExposeDataServer, false), Usage: "exposes a dedicated data server", EnvVars: []string{"STORAGE_HOME_EXPOSE_DATA_SERVER"}, Destination: &cfg.Reva.StorageHome.ExposeDataServer, }, &cli.StringFlag{ Name: "data-server-url", - Value: "http://localhost:9155/data", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.DataServerURL, "http://localhost:9155/data"), Usage: "data server url", EnvVars: []string{"STORAGE_HOME_DATA_SERVER_URL"}, Destination: &cfg.Reva.StorageHome.DataServerURL, }, &cli.StringFlag{ Name: "http-prefix", - Value: "data", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.HTTPPrefix, "data"), Usage: "prefix for the http endpoint, without leading slash", EnvVars: []string{"STORAGE_HOME_HTTP_PREFIX"}, Destination: &cfg.Reva.StorageHome.HTTPPrefix, }, &cli.StringFlag{ Name: "tmp-folder", - Value: "/var/tmp/ocis/tmp/home", + Value: flags.OverrideDefaultString(cfg.Reva.StorageHome.TempFolder, "/var/tmp/ocis/tmp/home"), Usage: "path to tmp folder", EnvVars: []string{"STORAGE_HOME_TMP_FOLDER"}, Destination: &cfg.Reva.StorageHome.TempFolder, }, &cli.BoolFlag{ Name: "enable-home", - Value: true, + Value: flags.OverrideDefaultBool(cfg.Reva.Storages.Home.EnableHome, true), Usage: "enable the creation of home directories", EnvVars: []string{"STORAGE_HOME_ENABLE_HOME"}, Destination: &cfg.Reva.Storages.Home.EnableHome, @@ -132,7 +133,7 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-endpoint", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "endpoint to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, @@ -141,7 +142,7 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "users-endpoint", - Value: "localhost:9144", + Value: flags.OverrideDefaultString(cfg.Reva.Users.Endpoint, "localhost:9144"), Usage: "endpoint to use for the storage service", EnvVars: []string{"STORAGE_USERPROVIDER_ENDPOINT"}, Destination: &cfg.Reva.Users.Endpoint, diff --git a/storage/pkg/flagset/storagepubliclink.go b/storage/pkg/flagset/storagepubliclink.go index c3e4c505e..eefc636a3 100644 --- a/storage/pkg/flagset/storagepubliclink.go +++ b/storage/pkg/flagset/storagepubliclink.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -11,7 +12,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9179", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.DebugAddr, "0.0.0.0:9179"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_PUBLIC_LINK_DEBUG_ADDR"}, Destination: &cfg.Reva.StoragePublicLink.DebugAddr, @@ -19,14 +20,14 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_PUBLIC_LINK_GRPC_NETWORK"}, Destination: &cfg.Reva.StoragePublicLink.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9178", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.GRPCAddr, "0.0.0.0:9178"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_PUBLIC_LINK_GRPC_ADDR"}, Destination: &cfg.Reva.StoragePublicLink.GRPCAddr, @@ -34,7 +35,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "mount-path", - Value: "/public", + Value: flags.OverrideDefaultString(cfg.Reva.StoragePublicLink.MountPath, "/public"), Usage: "mount path", EnvVars: []string{"STORAGE_PUBLIC_LINK_MOUNT_PATH"}, Destination: &cfg.Reva.StoragePublicLink.MountPath, @@ -42,7 +43,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-endpoint", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "endpoint to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, diff --git a/storage/pkg/flagset/storageusers.go b/storage/pkg/flagset/storageusers.go index 4e6c3be75..70ba25b7c 100644 --- a/storage/pkg/flagset/storageusers.go +++ b/storage/pkg/flagset/storageusers.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9159", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.DebugAddr, "0.0.0.0:9159"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_USERS_DEBUG_ADDR"}, Destination: &cfg.Reva.StorageUsers.DebugAddr, @@ -24,28 +25,28 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "grpc-network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.GRPCNetwork, "tcp"), Usage: "Network to use for the users storage, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_USERS_GRPC_NETWORK"}, Destination: &cfg.Reva.StorageUsers.GRPCNetwork, }, &cli.StringFlag{ Name: "grpc-addr", - Value: "0.0.0.0:9157", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.GRPCAddr, "0.0.0.0:9157"), Usage: "GRPC Address to bind users storage", EnvVars: []string{"STORAGE_USERS_GRPC_ADDR"}, Destination: &cfg.Reva.StorageUsers.GRPCAddr, }, &cli.StringFlag{ Name: "http-network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.HTTPNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_USERS_HTTP_NETWORK"}, Destination: &cfg.Reva.StorageUsers.HTTPNetwork, }, &cli.StringFlag{ Name: "http-addr", - Value: "0.0.0.0:9158", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.HTTPAddr, "0.0.0.0:9158"), Usage: "HTTP Address to bind users storage", EnvVars: []string{"STORAGE_USERS_HTTP_ADDR"}, Destination: &cfg.Reva.StorageUsers.HTTPAddr, @@ -68,49 +69,49 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "driver", - Value: "ocis", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.Driver, "ocis"), Usage: "storage driver for users mount: eg. local, eos, owncloud, ocis or s3", EnvVars: []string{"STORAGE_USERS_DRIVER"}, Destination: &cfg.Reva.StorageUsers.Driver, }, &cli.StringFlag{ Name: "mount-path", - Value: "/users", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.MountPath, "/users"), Usage: "mount path", EnvVars: []string{"STORAGE_USERS_MOUNT_PATH"}, Destination: &cfg.Reva.StorageUsers.MountPath, }, &cli.StringFlag{ Name: "mount-id", - Value: "1284d238-aa92-42ce-bdc4-0b0000009157", // /users + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.MountID, "1284d238-aa92-42ce-bdc4-0b0000009157"), Usage: "mount id", EnvVars: []string{"STORAGE_USERS_MOUNT_ID"}, Destination: &cfg.Reva.StorageUsers.MountID, }, &cli.BoolFlag{ Name: "expose-data-server", - Value: false, + Value: flags.OverrideDefaultBool(cfg.Reva.StorageUsers.ExposeDataServer, false), Usage: "exposes a dedicated data server", EnvVars: []string{"STORAGE_USERS_EXPOSE_DATA_SERVER"}, Destination: &cfg.Reva.StorageUsers.ExposeDataServer, }, &cli.StringFlag{ Name: "data-server-url", - Value: "http://localhost:9158/data", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.DataServerURL, "http://localhost:9158/data"), Usage: "data server url", EnvVars: []string{"STORAGE_USERS_DATA_SERVER_URL"}, Destination: &cfg.Reva.StorageUsers.DataServerURL, }, &cli.StringFlag{ Name: "http-prefix", - Value: "data", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.HTTPPrefix, "data"), Usage: "prefix for the http endpoint, without leading slash", EnvVars: []string{"STORAGE_USERS_HTTP_PREFIX"}, Destination: &cfg.Reva.StorageUsers.HTTPPrefix, }, &cli.StringFlag{ Name: "tmp-folder", - Value: "/var/tmp/ocis/tmp/users", + Value: flags.OverrideDefaultString(cfg.Reva.StorageUsers.TempFolder, "/var/tmp/ocis/tmp/users"), Usage: "path to tmp folder", EnvVars: []string{"STORAGE_USERS_TMP_FOLDER"}, Destination: &cfg.Reva.StorageUsers.TempFolder, @@ -122,7 +123,7 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "gateway-endpoint", - Value: "localhost:9142", + Value: flags.OverrideDefaultString(cfg.Reva.Gateway.Endpoint, "localhost:9142"), Usage: "endpoint to use for the storage gateway service", EnvVars: []string{"STORAGE_GATEWAY_ENDPOINT"}, Destination: &cfg.Reva.Gateway.Endpoint, @@ -131,7 +132,7 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "users-endpoint", - Value: "localhost:9144", + Value: flags.OverrideDefaultString(cfg.Reva.Users.Endpoint, "localhost:9144"), Usage: "endpoint to use for the storage service", EnvVars: []string{"STORAGE_USERPROVIDER_ENDPOINT"}, Destination: &cfg.Reva.Users.Endpoint, diff --git a/storage/pkg/flagset/tracing.go b/storage/pkg/flagset/tracing.go index bf0540458..43daa268e 100644 --- a/storage/pkg/flagset/tracing.go +++ b/storage/pkg/flagset/tracing.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -17,28 +18,28 @@ func TracingWithConfig(cfg *config.Config) []cli.Flag { }, &cli.StringFlag{ Name: "tracing-type", - Value: "jaeger", + Value: flags.OverrideDefaultString(cfg.Tracing.Type, "jaeger"), Usage: "Tracing backend type", EnvVars: []string{"STORAGE_TRACING_TYPE"}, Destination: &cfg.Tracing.Type, }, &cli.StringFlag{ Name: "tracing-endpoint", - Value: "", + Value: flags.OverrideDefaultString(cfg.Tracing.Endpoint, ""), Usage: "Endpoint for the agent", EnvVars: []string{"STORAGE_TRACING_ENDPOINT"}, Destination: &cfg.Tracing.Endpoint, }, &cli.StringFlag{ Name: "tracing-collector", - Value: "", + Value: flags.OverrideDefaultString(cfg.Tracing.Collector, ""), Usage: "Endpoint for the collector", EnvVars: []string{"STORAGE_TRACING_COLLECTOR"}, Destination: &cfg.Tracing.Collector, }, &cli.StringFlag{ Name: "tracing-service", - Value: "storage", + Value: flags.OverrideDefaultString(cfg.Tracing.Service, "storage"), Usage: "Service name for tracing", EnvVars: []string{"STORAGE_TRACING_SERVICE"}, Destination: &cfg.Tracing.Service, diff --git a/storage/pkg/flagset/users.go b/storage/pkg/flagset/users.go index 31120c8f9..091cefb12 100644 --- a/storage/pkg/flagset/users.go +++ b/storage/pkg/flagset/users.go @@ -2,6 +2,7 @@ package flagset import ( "github.com/micro/cli/v2" + "github.com/owncloud/ocis/ocis-pkg/flags" "github.com/owncloud/ocis/storage/pkg/config" ) @@ -12,7 +13,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { // debug ports are the odd ports &cli.StringFlag{ Name: "debug-addr", - Value: "0.0.0.0:9145", + Value: flags.OverrideDefaultString(cfg.Reva.Users.DebugAddr, "0.0.0.0:9145"), Usage: "Address to bind debug server", EnvVars: []string{"STORAGE_SHARING_DEBUG_ADDR"}, Destination: &cfg.Reva.Users.DebugAddr, @@ -24,21 +25,21 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "network", - Value: "tcp", + Value: flags.OverrideDefaultString(cfg.Reva.Users.GRPCNetwork, "tcp"), Usage: "Network to use for the storage service, can be 'tcp', 'udp' or 'unix'", EnvVars: []string{"STORAGE_USERPROVIDER_NETWORK"}, Destination: &cfg.Reva.Users.GRPCNetwork, }, &cli.StringFlag{ Name: "addr", - Value: "0.0.0.0:9144", + Value: flags.OverrideDefaultString(cfg.Reva.Users.GRPCAddr, "0.0.0.0:9144"), Usage: "Address to bind storage service", EnvVars: []string{"STORAGE_USERPROVIDER_ADDR"}, Destination: &cfg.Reva.Users.GRPCAddr, }, &cli.StringFlag{ Name: "endpoint", - Value: "localhost:9144", + Value: flags.OverrideDefaultString(cfg.Reva.Users.Endpoint, "localhost:9144"), Usage: "URL to use for the storage service", EnvVars: []string{"STORAGE_USERPROVIDER_ENDPOINT"}, Destination: &cfg.Reva.Users.Endpoint, @@ -52,21 +53,21 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag { &cli.StringFlag{ Name: "driver", - Value: "ldap", + Value: flags.OverrideDefaultString(cfg.Reva.Users.Driver, "ldap"), Usage: "user driver: 'demo', 'json', 'ldap', or 'rest'", EnvVars: []string{"STORAGE_USERPROVIDER_DRIVER"}, Destination: &cfg.Reva.Users.Driver, }, &cli.StringFlag{ Name: "json-config", - Value: "", + Value: flags.OverrideDefaultString(cfg.Reva.Users.JSON, ""), Usage: "Path to users.json file", EnvVars: []string{"STORAGE_USERPROVIDER_JSON"}, Destination: &cfg.Reva.Users.JSON, }, &cli.IntFlag{ Name: "user-groups-cache-expiration", - Value: 5, + Value: flags.OverrideDefaultInt(cfg.Reva.Users.UserGroupsCacheExpiration, 5), Usage: "Time in minutes for redis cache expiration.", EnvVars: []string{"STORAGE_USER_CACHE_EXPIRATION"}, Destination: &cfg.Reva.Users.UserGroupsCacheExpiration,