From e373e4838318ca18873152fe277a0e78b7b436a9 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 12 Oct 2022 15:48:54 +0200 Subject: [PATCH] Get rid of duplicated Reva config struct Consolidate all services to use the Reva config struct for the shared package. This works because all services (except 'notifications', 'thumbnails' and 'webdav') where using the same config keys and environment variables for setting the reva gateway. --- services/app-provider/pkg/config/config.go | 2 +- .../app-provider/pkg/config/defaults/defaultconfig.go | 6 +++--- services/app-provider/pkg/config/reva.go | 5 ----- services/app-registry/pkg/config/config.go | 2 +- .../app-registry/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/app-registry/pkg/config/reva.go | 5 ----- services/auth-basic/pkg/config/config.go | 2 +- .../auth-basic/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/auth-basic/pkg/config/reva.go | 5 ----- services/auth-bearer/pkg/config/config.go | 2 +- .../auth-bearer/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/auth-bearer/pkg/config/reva.go | 5 ----- services/auth-machine/pkg/config/config.go | 2 +- .../auth-machine/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/auth-machine/pkg/config/reva.go | 5 ----- services/frontend/pkg/config/config.go | 2 +- services/frontend/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/frontend/pkg/config/reva.go | 5 ----- services/gateway/pkg/config/config.go | 2 +- services/gateway/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/gateway/pkg/config/reva.go | 5 ----- services/graph/pkg/config/config.go | 2 +- services/graph/pkg/config/defaults/defaultconfig.go | 3 ++- services/graph/pkg/config/reva.go | 5 ----- services/graph/pkg/identity/cs3.go | 4 ++-- services/groups/pkg/config/config.go | 2 +- services/groups/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/groups/pkg/config/reva.go | 5 ----- services/idp/pkg/config/config.go | 2 +- services/idp/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/idp/pkg/config/reva.go | 6 ------ services/notifications/pkg/channels/channels.go | 2 +- services/notifications/pkg/command/server.go | 4 ++-- services/notifications/pkg/config/config.go | 10 +++++----- .../notifications/pkg/config/defaults/defaultconfig.go | 5 ++++- services/ocdav/pkg/config/config.go | 2 +- services/ocdav/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/ocdav/pkg/config/reva.go | 5 ----- services/ocs/pkg/config/config.go | 2 +- services/ocs/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/ocs/pkg/config/reva.go | 5 ----- services/proxy/pkg/config/config.go | 2 +- services/proxy/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/proxy/pkg/config/reva.go | 6 ------ services/search/pkg/config/config.go | 6 +++--- services/search/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/search/pkg/config/reva.go | 6 ------ services/sharing/pkg/config/config.go | 2 +- services/sharing/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/sharing/pkg/config/reva.go | 5 ----- services/storage-publiclink/pkg/config/config.go | 2 +- .../pkg/config/defaults/defaultconfig.go | 7 ++++--- services/storage-publiclink/pkg/config/reva.go | 5 ----- services/storage-shares/pkg/config/config.go | 2 +- .../pkg/config/defaults/defaultconfig.go | 7 ++++--- services/storage-shares/pkg/config/reva.go | 5 ----- services/storage-system/pkg/config/config.go | 2 +- .../pkg/config/defaults/defaultconfig.go | 7 ++++--- services/storage-system/pkg/config/reva.go | 5 ----- services/storage-users/pkg/config/config.go | 2 +- .../storage-users/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/storage-users/pkg/config/reva.go | 5 ----- services/thumbnails/pkg/config/config.go | 2 +- .../thumbnails/pkg/config/defaults/defaultconfig.go | 9 ++++++--- services/thumbnails/pkg/server/grpc/server.go | 2 +- services/users/pkg/config/config.go | 2 +- services/users/pkg/config/defaults/defaultconfig.go | 7 ++++--- services/users/pkg/config/reva.go | 5 ----- services/webdav/pkg/config/config.go | 9 ++++----- services/webdav/pkg/config/defaults/defaultconfig.go | 5 ++++- services/webdav/pkg/service/v0/service.go | 2 +- 71 files changed, 130 insertions(+), 206 deletions(-) delete mode 100644 services/idp/pkg/config/reva.go delete mode 100644 services/proxy/pkg/config/reva.go delete mode 100644 services/search/pkg/config/reva.go diff --git a/services/app-provider/pkg/config/config.go b/services/app-provider/pkg/config/config.go index c6f84da93d..d77524228b 100644 --- a/services/app-provider/pkg/config/config.go +++ b/services/app-provider/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` ExternalAddr string `yaml:"external_addr" env:"APP_PROVIDER_EXTERNAL_ADDR" desc:"Address of the app provider, where the GATEWAY service can reach it."` Driver string `yaml:"driver" env:"APP_PROVIDER_DRIVER" desc:"Driver, the APP PROVIDER services uses. Only \"wopi\" is supported as of now."` diff --git a/services/app-provider/pkg/config/defaults/defaultconfig.go b/services/app-provider/pkg/config/defaults/defaultconfig.go index 2ba8a992e4..8f045fe2ca 100644 --- a/services/app-provider/pkg/config/defaults/defaultconfig.go +++ b/services/app-provider/pkg/config/defaults/defaultconfig.go @@ -28,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "app-provider", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Driver: "", @@ -66,11 +66,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/app-provider/pkg/config/reva.go b/services/app-provider/pkg/config/reva.go index 135052cdcc..9290c1ac4a 100644 --- a/services/app-provider/pkg/config/reva.go +++ b/services/app-provider/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;APP_PROVIDER_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/app-registry/pkg/config/config.go b/services/app-registry/pkg/config/config.go index 817d0b91b7..b095d5afb2 100644 --- a/services/app-registry/pkg/config/config.go +++ b/services/app-registry/pkg/config/config.go @@ -17,7 +17,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` AppRegistry AppRegistry `yaml:"app_registry"` diff --git a/services/app-registry/pkg/config/defaults/defaultconfig.go b/services/app-registry/pkg/config/defaults/defaultconfig.go index c754f4e506..3764bedf65 100644 --- a/services/app-registry/pkg/config/defaults/defaultconfig.go +++ b/services/app-registry/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/app-registry/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "app-registry", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, } @@ -130,11 +131,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/app-registry/pkg/config/reva.go b/services/app-registry/pkg/config/reva.go index 13e56d8da2..bc7eddf4fd 100644 --- a/services/app-registry/pkg/config/reva.go +++ b/services/app-registry/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;APP_REGISTRY_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/auth-basic/pkg/config/config.go b/services/auth-basic/pkg/config/config.go index 1458ca1078..b9352319ac 100644 --- a/services/auth-basic/pkg/config/config.go +++ b/services/auth-basic/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"AUTH_BASIC_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the encoding of the user's group memberships in the reva access token. This reduces the token size, especially when users are members of a large number of groups."` AuthProvider string `yaml:"auth_provider" env:"AUTH_BASIC_AUTH_PROVIDER" desc:"The auth provider which should be used by the service like 'ldap'."` diff --git a/services/auth-basic/pkg/config/defaults/defaultconfig.go b/services/auth-basic/pkg/config/defaults/defaultconfig.go index a84df115d4..944872224e 100644 --- a/services/auth-basic/pkg/config/defaults/defaultconfig.go +++ b/services/auth-basic/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/auth-basic/pkg/config" ) @@ -30,7 +31,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "auth-basic", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, AuthProvider: "ldap", @@ -104,11 +105,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/auth-basic/pkg/config/reva.go b/services/auth-basic/pkg/config/reva.go index 57793f4bcd..6242d1caa5 100644 --- a/services/auth-basic/pkg/config/reva.go +++ b/services/auth-basic/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;AUTH_BASIC_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/auth-bearer/pkg/config/config.go b/services/auth-bearer/pkg/config/config.go index 5503a2cefc..03bd728694 100644 --- a/services/auth-bearer/pkg/config/config.go +++ b/services/auth-bearer/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"AUTH_BEARER_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the encoding of the user's group memberships in the reva access token. This reduces the token size, especially when users are members of a large number of groups."` diff --git a/services/auth-bearer/pkg/config/defaults/defaultconfig.go b/services/auth-bearer/pkg/config/defaults/defaultconfig.go index 5b5aabdbd8..9386f68a21 100644 --- a/services/auth-bearer/pkg/config/defaults/defaultconfig.go +++ b/services/auth-bearer/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "auth-bearer", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, OIDC: config.OIDC{ @@ -63,11 +64,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/auth-bearer/pkg/config/reva.go b/services/auth-bearer/pkg/config/reva.go index 5335b8a728..d556a05231 100644 --- a/services/auth-bearer/pkg/config/reva.go +++ b/services/auth-bearer/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;AUTH_BEARER_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/auth-machine/pkg/config/config.go b/services/auth-machine/pkg/config/config.go index d0b2c0b545..efdd2747ff 100644 --- a/services/auth-machine/pkg/config/config.go +++ b/services/auth-machine/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"AUTH_MACHINE_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the encoding of the user's group memberships in the reva access token. This reduces the token size, especially when users are members of a large number of groups."` diff --git a/services/auth-machine/pkg/config/defaults/defaultconfig.go b/services/auth-machine/pkg/config/defaults/defaultconfig.go index c861f8b385..d34a332cbc 100644 --- a/services/auth-machine/pkg/config/defaults/defaultconfig.go +++ b/services/auth-machine/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/auth-machine/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "auth-machine", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, } @@ -58,11 +59,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/auth-machine/pkg/config/reva.go b/services/auth-machine/pkg/config/reva.go index 099a5b3fe3..14cb00d089 100644 --- a/services/auth-machine/pkg/config/reva.go +++ b/services/auth-machine/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;AUTH_MACHINE_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index a3b92de916..2af685f4a1 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -20,7 +20,7 @@ type Config struct { TransferSecret string `yaml:"transfer_secret" env:"STORAGE_TRANSFER_SECRET" desc:"Transfer secret for signing file up- and download requests."` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;FRONTEND_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary to access resources from other services."` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"FRONTEND_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/frontend/pkg/config/defaults/defaultconfig.go b/services/frontend/pkg/config/defaults/defaultconfig.go index b70f8095c7..6ff6341fc0 100644 --- a/services/frontend/pkg/config/defaults/defaultconfig.go +++ b/services/frontend/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/frontend/pkg/config" ) @@ -28,7 +29,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "frontend", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, PublicURL: "https://localhost:9200", @@ -97,11 +98,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/frontend/pkg/config/reva.go b/services/frontend/pkg/config/reva.go index 8f0f7d14e7..c24d8b808e 100644 --- a/services/frontend/pkg/config/reva.go +++ b/services/frontend/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;FRONTEND_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/gateway/pkg/config/config.go b/services/gateway/pkg/config/config.go index 0114bb8c66..b0f4ce048c 100644 --- a/services/gateway/pkg/config/config.go +++ b/services/gateway/pkg/config/config.go @@ -17,7 +17,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"GATEWAY_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/gateway/pkg/config/defaults/defaultconfig.go b/services/gateway/pkg/config/defaults/defaultconfig.go index 94b9b32ace..2681f8332e 100644 --- a/services/gateway/pkg/config/defaults/defaultconfig.go +++ b/services/gateway/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/gateway/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "gateway", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, @@ -88,11 +89,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/gateway/pkg/config/reva.go b/services/gateway/pkg/config/reva.go index b781f8c32b..957e54590d 100644 --- a/services/gateway/pkg/config/reva.go +++ b/services/gateway/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;GATEWAY_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/graph/pkg/config/config.go b/services/graph/pkg/config/config.go index 7caa0b643c..a4f19e1150 100644 --- a/services/graph/pkg/config/config.go +++ b/services/graph/pkg/config/config.go @@ -19,7 +19,7 @@ type Config struct { HTTP HTTP `yaml:"http"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` TokenManager *TokenManager `yaml:"token_manager"` Spaces Spaces `yaml:"spaces"` diff --git a/services/graph/pkg/config/defaults/defaultconfig.go b/services/graph/pkg/config/defaults/defaultconfig.go index 34d05c2b09..0739d218a2 100644 --- a/services/graph/pkg/config/defaults/defaultconfig.go +++ b/services/graph/pkg/config/defaults/defaultconfig.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/graph/pkg/config" ) @@ -29,7 +30,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "graph", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Spaces: config.Spaces{ diff --git a/services/graph/pkg/config/reva.go b/services/graph/pkg/config/reva.go index 4bacfc5762..e9314b7fc8 100644 --- a/services/graph/pkg/config/reva.go +++ b/services/graph/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;GRAPH_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/graph/pkg/identity/cs3.go b/services/graph/pkg/identity/cs3.go index 015de11917..af1496e0f4 100644 --- a/services/graph/pkg/identity/cs3.go +++ b/services/graph/pkg/identity/cs3.go @@ -11,7 +11,7 @@ import ( libregraph "github.com/owncloud/libre-graph-api-go" "github.com/owncloud/ocis/v2/ocis-pkg/log" - "github.com/owncloud/ocis/v2/services/graph/pkg/config" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode" ) @@ -20,7 +20,7 @@ var ( ) type CS3 struct { - Config *config.Reva + Config *shared.Reva Logger *log.Logger } diff --git a/services/groups/pkg/config/config.go b/services/groups/pkg/config/config.go index fb8e9ed13b..56760e67fb 100644 --- a/services/groups/pkg/config/config.go +++ b/services/groups/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"GROUPS_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/groups/pkg/config/defaults/defaultconfig.go b/services/groups/pkg/config/defaults/defaultconfig.go index 822efa66dd..351d4f8887 100644 --- a/services/groups/pkg/config/defaults/defaultconfig.go +++ b/services/groups/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/groups/pkg/config" ) @@ -30,7 +31,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "groups", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Driver: "ldap", @@ -105,11 +106,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/groups/pkg/config/reva.go b/services/groups/pkg/config/reva.go index 82239b44c4..ff28fdecf5 100644 --- a/services/groups/pkg/config/reva.go +++ b/services/groups/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;GROUPS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/idp/pkg/config/config.go b/services/idp/pkg/config/config.go index 385ff180d3..515b6970c3 100644 --- a/services/idp/pkg/config/config.go +++ b/services/idp/pkg/config/config.go @@ -18,7 +18,7 @@ type Config struct { HTTP HTTP `yaml:"http"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;IDP_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services."` diff --git a/services/idp/pkg/config/defaults/defaultconfig.go b/services/idp/pkg/config/defaults/defaultconfig.go index 5076544959..0bff438f45 100644 --- a/services/idp/pkg/config/defaults/defaultconfig.go +++ b/services/idp/pkg/config/defaults/defaultconfig.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/idp/pkg/config" ) @@ -28,7 +29,7 @@ func DefaultConfig() *config.Config { TLSKey: filepath.Join(defaults.BaseDataPath(), "idp", "server.key"), TLS: false, }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Service: config.Service{ @@ -153,11 +154,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" { diff --git a/services/idp/pkg/config/reva.go b/services/idp/pkg/config/reva.go deleted file mode 100644 index 5b4222251d..0000000000 --- a/services/idp/pkg/config/reva.go +++ /dev/null @@ -1,6 +0,0 @@ -package config - -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"CS3 gateway used to authenticate and look up users"` -} diff --git a/services/notifications/pkg/channels/channels.go b/services/notifications/pkg/channels/channels.go index 59928fbc26..c1a018e6d8 100644 --- a/services/notifications/pkg/channels/channels.go +++ b/services/notifications/pkg/channels/channels.go @@ -27,7 +27,7 @@ type Channel interface { // NewMailChannel instantiates a new mail communication channel. func NewMailChannel(cfg config.Config, logger log.Logger) (Channel, error) { - gc, err := pool.GetGatewayServiceClient(cfg.Notifications.RevaGateway) + gc, err := pool.GetGatewayServiceClient(cfg.Notifications.Reva.Address) if err != nil { logger.Error().Err(err).Msg("could not get gateway client") return nil, err diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index c27787ac33..c2448efe8b 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -77,9 +77,9 @@ func Server(cfg *config.Config) *cli.Command { if err != nil { return err } - gwclient, err := pool.GetGatewayServiceClient(cfg.Notifications.RevaGateway) + gwclient, err := pool.GetGatewayServiceClient(cfg.Notifications.Reva.Address) if err != nil { - logger.Fatal().Err(err).Str("addr", cfg.Notifications.RevaGateway).Msg("could not get reva client") + logger.Fatal().Err(err).Str("addr", cfg.Notifications.Reva.Address).Msg("could not get reva client") } svc := service.NewEventsNotifier(evts, channel, logger, gwclient, cfg.Notifications.MachineAuthAPIKey, cfg.Notifications.EmailTemplatePath, cfg.Commons.OcisURL) diff --git a/services/notifications/pkg/config/config.go b/services/notifications/pkg/config/config.go index fae9ec89e8..652dc32dd5 100644 --- a/services/notifications/pkg/config/config.go +++ b/services/notifications/pkg/config/config.go @@ -22,11 +22,11 @@ type Config struct { // Notifications defines the config options for the notifications service. type Notifications struct { - SMTP SMTP `yaml:"SMTP"` - Events Events `yaml:"events"` - RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY;NOTIFICATIONS_REVA_GATEWAY" desc:"CS3 gateway used to look up user metadata"` - MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;NOTIFICATIONS_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary to access resources from other services."` - EmailTemplatePath string `yaml:"email_template_path" env:"OCIS_EMAIL_TEMPLATE_PATH;NOTIFICATIONS_EMAIL_TEMPLATE_PATH" desc:"Path to Email notification templates overriding embedded ones."` + SMTP SMTP `yaml:"SMTP"` + Events Events `yaml:"events"` + MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;NOTIFICATIONS_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary to access resources from other services."` + Reva shared.Reva `yaml:"reva"` + EmailTemplatePath string `yaml:"email_template_path" env:"OCIS_EMAIL_TEMPLATE_PATH;NOTIFICATIONS_EMAIL_TEMPLATE_PATH" desc:"Path to Email notification templates overriding embedded ones."` } // SMTP combines the smtp configuration options. diff --git a/services/notifications/pkg/config/defaults/defaultconfig.go b/services/notifications/pkg/config/defaults/defaultconfig.go index 53f8faa1d6..5d7d9fdd75 100644 --- a/services/notifications/pkg/config/defaults/defaultconfig.go +++ b/services/notifications/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/notifications/pkg/config" ) @@ -36,7 +37,9 @@ func DefaultConfig() *config.Config { ConsumerGroup: "notifications", EnableTLS: false, }, - RevaGateway: "127.0.0.1:9142", + Reva: shared.Reva{ + Address: "127.0.0.1:9142", + }, }, } } diff --git a/services/ocdav/pkg/config/config.go b/services/ocdav/pkg/config/config.go index 3ed98bf3e7..9f2d3f12f6 100644 --- a/services/ocdav/pkg/config/config.go +++ b/services/ocdav/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { HTTP HTTPConfig `yaml:"http"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"OCDAV_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/ocdav/pkg/config/defaults/defaultconfig.go b/services/ocdav/pkg/config/defaults/defaultconfig.go index 23d2c9561e..11051c346c 100644 --- a/services/ocdav/pkg/config/defaults/defaultconfig.go +++ b/services/ocdav/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/ocis-pkg/version" "github.com/owncloud/ocis/v2/services/ocdav/pkg/config" ) @@ -29,7 +30,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "ocdav", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, WebdavNamespace: "/users/{{.Id.OpaqueId}}", @@ -80,11 +81,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/ocdav/pkg/config/reva.go b/services/ocdav/pkg/config/reva.go index 60374747e5..6c772dafa7 100644 --- a/services/ocdav/pkg/config/reva.go +++ b/services/ocdav/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;OCDAV_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/ocs/pkg/config/config.go b/services/ocs/pkg/config/config.go index 9729fa19d7..4653d51686 100644 --- a/services/ocs/pkg/config/config.go +++ b/services/ocs/pkg/config/config.go @@ -20,7 +20,7 @@ type Config struct { HTTP HTTP `yaml:"http"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` IdentityManagement IdentityManagement `yaml:"identity_management"` diff --git a/services/ocs/pkg/config/defaults/defaultconfig.go b/services/ocs/pkg/config/defaults/defaultconfig.go index 7e9c03ea94..97ddd33941 100644 --- a/services/ocs/pkg/config/defaults/defaultconfig.go +++ b/services/ocs/pkg/config/defaults/defaultconfig.go @@ -3,6 +3,7 @@ package defaults import ( "strings" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/ocs/pkg/config" ) @@ -36,7 +37,7 @@ func DefaultConfig() *config.Config { Name: "ocs", }, AccountBackend: "cs3", - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, IdentityManagement: config.IdentityManagement{ @@ -80,11 +81,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/ocs/pkg/config/reva.go b/services/ocs/pkg/config/reva.go index d4f77cdc55..149233e36a 100644 --- a/services/ocs/pkg/config/reva.go +++ b/services/ocs/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;OCS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/proxy/pkg/config/config.go b/services/proxy/pkg/config/config.go index 886351589f..c2b2236afd 100644 --- a/services/proxy/pkg/config/config.go +++ b/services/proxy/pkg/config/config.go @@ -18,7 +18,7 @@ type Config struct { HTTP HTTP `yaml:"http"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` Policies []Policy `yaml:"policies"` OIDC OIDC `yaml:"oidc"` diff --git a/services/proxy/pkg/config/defaults/defaultconfig.go b/services/proxy/pkg/config/defaults/defaultconfig.go index 06b5878c17..cd40c61f95 100644 --- a/services/proxy/pkg/config/defaults/defaultconfig.go +++ b/services/proxy/pkg/config/defaults/defaultconfig.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/proxy/pkg/config" ) @@ -48,7 +49,7 @@ func DefaultConfig() *config.Config { }, }, PolicySelector: nil, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, PreSignedURL: config.PreSignedURL{ @@ -242,11 +243,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } } diff --git a/services/proxy/pkg/config/reva.go b/services/proxy/pkg/config/reva.go deleted file mode 100644 index c84988f53c..0000000000 --- a/services/proxy/pkg/config/reva.go +++ /dev/null @@ -1,6 +0,0 @@ -package config - -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} diff --git a/services/search/pkg/config/config.go b/services/search/pkg/config/config.go index 5e4eed9344..b69832cd35 100644 --- a/services/search/pkg/config/config.go +++ b/services/search/pkg/config/config.go @@ -18,9 +18,9 @@ type Config struct { GRPC GRPC `yaml:"grpc"` - Datapath string `yaml:"data_path" env:"SEARCH_DATA_PATH" desc:"The directory where the filesystem storage will store search data. If not definied, the root directory derives from $OCIS_BASE_DATA_PATH:/search."` - Reva *Reva `yaml:"reva"` - Events Events `yaml:"events"` + Datapath string `yaml:"data_path" env:"SEARCH_DATA_PATH" desc:"The directory where the filesystem storage will store search data. If not definied, the root directory derives from $OCIS_BASE_DATA_PATH:/search."` + Reva *shared.Reva `yaml:"reva"` + Events Events `yaml:"events"` MachineAuthAPIKey string `yaml:"machine_auth_api_key" env:"OCIS_MACHINE_AUTH_API_KEY;SEARCH_MACHINE_AUTH_API_KEY" desc:"Machine auth API key used to validate internal requests necessary for the access to resources from other services."` diff --git a/services/search/pkg/config/defaults/defaultconfig.go b/services/search/pkg/config/defaults/defaultconfig.go index e3b2a5535a..495f8ec2ba 100644 --- a/services/search/pkg/config/defaults/defaultconfig.go +++ b/services/search/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/search/pkg/config" ) @@ -29,7 +30,7 @@ func DefaultConfig() *config.Config { Name: "search", }, Datapath: path.Join(defaults.BaseDataPath(), "search"), - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Events: config.Events{ @@ -72,11 +73,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } } diff --git a/services/search/pkg/config/reva.go b/services/search/pkg/config/reva.go deleted file mode 100644 index f0c218ad80..0000000000 --- a/services/search/pkg/config/reva.go +++ /dev/null @@ -1,6 +0,0 @@ -package config - -// Reva defines all available REVA configuration. -type Reva struct { - Address string `ocisConfig:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} diff --git a/services/sharing/pkg/config/config.go b/services/sharing/pkg/config/config.go index b9b2714f5c..9d35a5221c 100644 --- a/services/sharing/pkg/config/config.go +++ b/services/sharing/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` Events Events `yaml:"events"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"SHARING_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/sharing/pkg/config/defaults/defaultconfig.go b/services/sharing/pkg/config/defaults/defaultconfig.go index d404b874d1..5368f0337f 100644 --- a/services/sharing/pkg/config/defaults/defaultconfig.go +++ b/services/sharing/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/sharing/pkg/config" ) @@ -30,7 +31,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "sharing", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, UserSharingDriver: "jsoncs3", @@ -101,11 +102,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/sharing/pkg/config/reva.go b/services/sharing/pkg/config/reva.go index 85b7124dd8..2f0576e057 100644 --- a/services/sharing/pkg/config/reva.go +++ b/services/sharing/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;SHARING_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/storage-publiclink/pkg/config/config.go b/services/storage-publiclink/pkg/config/config.go index c2569e5196..311328f417 100644 --- a/services/storage-publiclink/pkg/config/config.go +++ b/services/storage-publiclink/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_PUBLICLINK_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go b/services/storage-publiclink/pkg/config/defaults/defaultconfig.go index 9d8670ebaf..229f3c19b4 100644 --- a/services/storage-publiclink/pkg/config/defaults/defaultconfig.go +++ b/services/storage-publiclink/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "storage-publiclink", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, StorageProvider: config.StorageProvider{ @@ -61,11 +62,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/storage-publiclink/pkg/config/reva.go b/services/storage-publiclink/pkg/config/reva.go index 06102c99d1..bc92edbfa8 100644 --- a/services/storage-publiclink/pkg/config/reva.go +++ b/services/storage-publiclink/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;STORAGE_PUBLICLINK_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/storage-shares/pkg/config/config.go b/services/storage-shares/pkg/config/config.go index 33a46d2ecb..8cacec592b 100644 --- a/services/storage-shares/pkg/config/config.go +++ b/services/storage-shares/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_SHARES_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/storage-shares/pkg/config/defaults/defaultconfig.go b/services/storage-shares/pkg/config/defaults/defaultconfig.go index 13047125a9..ef14adef8a 100644 --- a/services/storage-shares/pkg/config/defaults/defaultconfig.go +++ b/services/storage-shares/pkg/config/defaults/defaultconfig.go @@ -1,6 +1,7 @@ package defaults import ( + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/storage-shares/pkg/config" ) @@ -27,7 +28,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "storage-shares", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, MountID: "7639e57c-4433-4a12-8201-722fd0009154", @@ -61,11 +62,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/storage-shares/pkg/config/reva.go b/services/storage-shares/pkg/config/reva.go index 1905f490a3..dc5dd4dde1 100644 --- a/services/storage-shares/pkg/config/reva.go +++ b/services/storage-shares/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;STORAGE_SHARES_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/storage-system/pkg/config/config.go b/services/storage-system/pkg/config/config.go index 5a87745fc9..31b23ed723 100644 --- a/services/storage-system/pkg/config/config.go +++ b/services/storage-system/pkg/config/config.go @@ -17,7 +17,7 @@ type Config struct { HTTP HTTPConfig `yaml:"http"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SystemUserID string `yaml:"system_user_id" env:"OCIS_SYSTEM_USER_ID" desc:"ID of the oCIS storage-system system user. Admins need to set the ID for the STORAGE-SYSTEM system user in this config option which is then used to reference the user. Any reasonable long string is possible, preferably this would be an UUIDv4 format."` SystemUserAPIKey string `yaml:"system_user_api_key" env:"OCIS_SYSTEM_USER_API_KEY" desc:"API key for the STORAGE-SYSTEM system user."` diff --git a/services/storage-system/pkg/config/defaults/defaultconfig.go b/services/storage-system/pkg/config/defaults/defaultconfig.go index 99188634a8..57ba2fe4c8 100644 --- a/services/storage-system/pkg/config/defaults/defaultconfig.go +++ b/services/storage-system/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/storage-system/pkg/config" ) @@ -35,7 +36,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "storage-system", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, DataServerURL: "http://localhost:9216/data", @@ -73,11 +74,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/storage-system/pkg/config/reva.go b/services/storage-system/pkg/config/reva.go index f401016959..5c8ff6d4c2 100644 --- a/services/storage-system/pkg/config/reva.go +++ b/services/storage-system/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;STORAGE_SYSTEM_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/storage-users/pkg/config/config.go b/services/storage-users/pkg/config/config.go index 3081c42e02..d7b24f39f4 100644 --- a/services/storage-users/pkg/config/config.go +++ b/services/storage-users/pkg/config/config.go @@ -17,7 +17,7 @@ type Config struct { HTTP HTTPConfig `yaml:"http"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"STORAGE_USERS_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/storage-users/pkg/config/defaults/defaultconfig.go b/services/storage-users/pkg/config/defaults/defaultconfig.go index e1f98cb000..c6865dcda8 100644 --- a/services/storage-users/pkg/config/defaults/defaultconfig.go +++ b/services/storage-users/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/storage-users/pkg/config" ) @@ -36,7 +37,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "storage-users", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, DataServerURL: "http://localhost:9158/data", @@ -111,11 +112,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/storage-users/pkg/config/reva.go b/services/storage-users/pkg/config/reva.go index 3eed400065..de111cde31 100644 --- a/services/storage-users/pkg/config/reva.go +++ b/services/storage-users/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;STORAGE_USERS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/thumbnails/pkg/config/config.go b/services/thumbnails/pkg/config/config.go index 781a613f78..cd428e14d8 100644 --- a/services/thumbnails/pkg/config/config.go +++ b/services/thumbnails/pkg/config/config.go @@ -35,7 +35,7 @@ type Thumbnail struct { FileSystemStorage FileSystemStorage `yaml:"filesystem_storage"` WebdavAllowInsecure bool `yaml:"webdav_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_WEBDAVSOURCE_INSECURE" desc:"Ignore untrusted SSL certificates when connecting to the webdav source."` CS3AllowInsecure bool `yaml:"cs3_allow_insecure" env:"OCIS_INSECURE;THUMBNAILS_CS3SOURCE_INSECURE" desc:"Ignore untrusted SSL certificates when connecting to the CS3 source."` - RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` //TODO: use REVA config + Reva shared.Reva `yaml:"reva"` FontMapFile string `yaml:"font_map_file" env:"THUMBNAILS_TXT_FONTMAP_FILE" desc:"The path to a font file for txt thumbnails."` TransferSecret string `yaml:"transfer_secret" env:"THUMBNAILS_TRANSFER_TOKEN" desc:"The secret to sign JWT to download the actual thumbnail file."` DataEndpoint string `yaml:"data_endpoint" env:"THUMBNAILS_DATA_ENDPOINT" desc:"The HTTP endpoint where the actual thumbnail file can be downloaded."` diff --git a/services/thumbnails/pkg/config/defaults/defaultconfig.go b/services/thumbnails/pkg/config/defaults/defaultconfig.go index b6d3f8b7cd..b5dccb365d 100644 --- a/services/thumbnails/pkg/config/defaults/defaultconfig.go +++ b/services/thumbnails/pkg/config/defaults/defaultconfig.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/thumbnails/pkg/config" ) @@ -41,9 +42,11 @@ func DefaultConfig() *config.Config { RootDirectory: path.Join(defaults.BaseDataPath(), "thumbnails"), }, WebdavAllowInsecure: false, - RevaGateway: "127.0.0.1:9142", - CS3AllowInsecure: false, - DataEndpoint: "http://127.0.0.1:9186/thumbnails/data", + Reva: shared.Reva{ + Address: "127.0.0.1:9142", + }, + CS3AllowInsecure: false, + DataEndpoint: "http://127.0.0.1:9186/thumbnails/data", }, } } diff --git a/services/thumbnails/pkg/server/grpc/server.go b/services/thumbnails/pkg/server/grpc/server.go index 9f78524f0f..b8e8d8e268 100644 --- a/services/thumbnails/pkg/server/grpc/server.go +++ b/services/thumbnails/pkg/server/grpc/server.go @@ -26,7 +26,7 @@ func NewService(opts ...Option) grpc.Service { grpc.Version(version.GetString()), ) tconf := options.Config.Thumbnail - gc, err := pool.GetGatewayServiceClient(tconf.RevaGateway) + gc, err := pool.GetGatewayServiceClient(tconf.Reva.Address) if err != nil { options.Logger.Error().Err(err).Msg("could not get gateway client") return grpc.Service{} diff --git a/services/users/pkg/config/config.go b/services/users/pkg/config/config.go index 269151597b..0fb0ede101 100644 --- a/services/users/pkg/config/config.go +++ b/services/users/pkg/config/config.go @@ -16,7 +16,7 @@ type Config struct { GRPC GRPCConfig `yaml:"grpc"` TokenManager *TokenManager `yaml:"token_manager"` - Reva *Reva `yaml:"reva"` + Reva *shared.Reva `yaml:"reva"` SkipUserGroupsInToken bool `yaml:"skip_user_groups_in_token" env:"USERS_SKIP_USER_GROUPS_IN_TOKEN" desc:"Disables the loading of user's group memberships from the reva access token."` diff --git a/services/users/pkg/config/defaults/defaultconfig.go b/services/users/pkg/config/defaults/defaultconfig.go index 2f7e871703..2d93cc13ba 100644 --- a/services/users/pkg/config/defaults/defaultconfig.go +++ b/services/users/pkg/config/defaults/defaultconfig.go @@ -4,6 +4,7 @@ import ( "path/filepath" "github.com/owncloud/ocis/v2/ocis-pkg/config/defaults" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/users/pkg/config" ) @@ -30,7 +31,7 @@ func DefaultConfig() *config.Config { Service: config.Service{ Name: "users", }, - Reva: &config.Reva{ + Reva: &shared.Reva{ Address: "127.0.0.1:9142", }, Driver: "ldap", @@ -106,11 +107,11 @@ func EnsureDefaults(cfg *config.Config) { } if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil { - cfg.Reva = &config.Reva{ + cfg.Reva = &shared.Reva{ Address: cfg.Commons.Reva.Address, } } else if cfg.Reva == nil { - cfg.Reva = &config.Reva{} + cfg.Reva = &shared.Reva{} } if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil { diff --git a/services/users/pkg/config/reva.go b/services/users/pkg/config/reva.go index 110f374c45..5ae0005089 100644 --- a/services/users/pkg/config/reva.go +++ b/services/users/pkg/config/reva.go @@ -1,10 +1,5 @@ package config -// Reva defines all available REVA configuration. -type Reva struct { - Address string `yaml:"address" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` -} - // TokenManager is the config for using the reva token manager type TokenManager struct { JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;USERS_JWT_SECRET" desc:"The secret to mint and validate jwt tokens."` diff --git a/services/webdav/pkg/config/config.go b/services/webdav/pkg/config/config.go index 2e609335a0..5e7091983c 100644 --- a/services/webdav/pkg/config/config.go +++ b/services/webdav/pkg/config/config.go @@ -18,9 +18,8 @@ type Config struct { HTTP HTTP `yaml:"http"` - OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL" desc:"URL, where oCIS is reachable for users."` - WebdavNamespace string `yaml:"webdav_namespace" env:"WEBDAV_WEBDAV_NAMESPACE" desc:"CS3 path layout to use when forwarding /webdav requests"` - RevaGateway string `yaml:"reva_gateway" env:"REVA_GATEWAY" desc:"The CS3 gateway endpoint."` - - Context context.Context `yaml:"-"` + OcisPublicURL string `yaml:"ocis_public_url" env:"OCIS_URL;OCIS_PUBLIC_URL" desc:"URL, where oCIS is reachable for users."` + WebdavNamespace string `yaml:"webdav_namespace" env:"WEBDAV_WEBDAV_NAMESPACE" desc:"CS3 path layout to use when forwarding /webdav requests"` + Reva shared.Reva `yaml:"reva"` + Context context.Context `yaml:"-"` } diff --git a/services/webdav/pkg/config/defaults/defaultconfig.go b/services/webdav/pkg/config/defaults/defaultconfig.go index 12ded296c7..98e98d6c90 100644 --- a/services/webdav/pkg/config/defaults/defaultconfig.go +++ b/services/webdav/pkg/config/defaults/defaultconfig.go @@ -3,6 +3,7 @@ package defaults import ( "strings" + "github.com/owncloud/ocis/v2/ocis-pkg/shared" "github.com/owncloud/ocis/v2/services/webdav/pkg/config" ) @@ -37,7 +38,9 @@ func DefaultConfig() *config.Config { }, OcisPublicURL: "https://127.0.0.1:9200", WebdavNamespace: "/users/{{.Id.OpaqueId}}", - RevaGateway: "127.0.0.1:9142", + Reva: shared.Reva{ + Address: "127.0.0.1:9142", + }, } } diff --git a/services/webdav/pkg/service/v0/service.go b/services/webdav/pkg/service/v0/service.go index 1daa30deb8..be33cc7a5b 100644 --- a/services/webdav/pkg/service/v0/service.go +++ b/services/webdav/pkg/service/v0/service.go @@ -60,7 +60,7 @@ func NewService(opts ...Option) (Service, error) { // chi.RegisterMethod("REPORT") m.Use(options.Middleware...) - gwc, err := pool.GetGatewayServiceClient(conf.RevaGateway) + gwc, err := pool.GetGatewayServiceClient(conf.Reva.Address) if err != nil { return nil, err }