Skip to content

Commit

Permalink
Get rid of duplicated Reva config struct
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhafer committed Oct 12, 2022
1 parent a275c1c commit 2b4b29a
Show file tree
Hide file tree
Showing 71 changed files with 130 additions and 206 deletions.
2 changes: 1 addition & 1 deletion services/app-provider/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand Down
6 changes: 3 additions & 3 deletions services/app-provider/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/app-provider/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/app-registry/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
7 changes: 4 additions & 3 deletions services/app-registry/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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",
},
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/app-registry/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/auth-basic/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'."`
Expand Down
7 changes: 4 additions & 3 deletions services/auth-basic/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/auth-basic/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/auth-bearer/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`

Expand Down
7 changes: 4 additions & 3 deletions services/auth-bearer/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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{
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/auth-bearer/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/auth-machine/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`

Expand Down
7 changes: 4 additions & 3 deletions services/auth-machine/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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",
},
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/auth-machine/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/frontend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand Down
7 changes: 4 additions & 3 deletions services/frontend/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package defaults

import (
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/services/frontend/pkg/config"
)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/frontend/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/gateway/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`

Expand Down
7 changes: 4 additions & 3 deletions services/gateway/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package defaults

import (
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/services/gateway/pkg/config"
)

Expand All @@ -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",
},

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions services/gateway/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
2 changes: 1 addition & 1 deletion services/graph/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion services/graph/pkg/config/defaults/defaultconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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{
Expand Down
5 changes: 0 additions & 5 deletions services/graph/pkg/config/reva.go
Original file line number Diff line number Diff line change
@@ -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."`
Expand Down
Loading

0 comments on commit 2b4b29a

Please sign in to comment.