reduce duplication in configuration code

This commit is contained in:
David Christofas
2023-03-03 00:39:00 +01:00
parent 006b3cfba6
commit 63fa35fa50
29 changed files with 175 additions and 352 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/owncloud/ocis/v2/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/ocis-pkg/structs"
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
)
@@ -130,12 +131,8 @@ func EnsureDefaults(cfg *config.Config) {
cfg.TokenManager = &config.TokenManager{}
}
if cfg.GRPCClientTLS == nil {
cfg.GRPCClientTLS = &shared.GRPCClientTLS{}
if cfg.Commons != nil && cfg.Commons.GRPCClientTLS != nil {
cfg.GRPCClientTLS.Mode = cfg.Commons.GRPCClientTLS.Mode
cfg.GRPCClientTLS.CACert = cfg.Commons.GRPCClientTLS.CACert
}
if cfg.GRPCClientTLS == nil && cfg.Commons != nil {
cfg.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS)
}
if cfg.Commons != nil {