From fe4cd7a9016ffefeda8fcc91a72266964f2e5f72 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Tue, 19 Mar 2024 14:21:21 +0100 Subject: [PATCH] make code more readable Signed-off-by: Christian Richter --- services/frontend/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/invitations/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/ocdav/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/ocm/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/storage-users/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/web/pkg/config/defaults/defaultconfig.go | 6 ++++-- services/webfinger/pkg/config/defaults/defaultconfig.go | 6 ++++-- 7 files changed, 28 insertions(+), 14 deletions(-) diff --git a/services/frontend/pkg/config/defaults/defaultconfig.go b/services/frontend/pkg/config/defaults/defaultconfig.go index c984e469d..c38c40f59 100644 --- a/services/frontend/pkg/config/defaults/defaultconfig.go +++ b/services/frontend/pkg/config/defaults/defaultconfig.go @@ -185,8 +185,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/invitations/pkg/config/defaults/defaultconfig.go b/services/invitations/pkg/config/defaults/defaultconfig.go index 8eb09dc01..840ee0c7c 100644 --- a/services/invitations/pkg/config/defaults/defaultconfig.go +++ b/services/invitations/pkg/config/defaults/defaultconfig.go @@ -78,8 +78,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.TokenManager = &config.TokenManager{} } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/ocdav/pkg/config/defaults/defaultconfig.go b/services/ocdav/pkg/config/defaults/defaultconfig.go index 535ed3e0a..0008a45e4 100644 --- a/services/ocdav/pkg/config/defaults/defaultconfig.go +++ b/services/ocdav/pkg/config/defaults/defaultconfig.go @@ -138,8 +138,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/ocm/pkg/config/defaults/defaultconfig.go b/services/ocm/pkg/config/defaults/defaultconfig.go index 1b7b346f0..91d1503ef 100644 --- a/services/ocm/pkg/config/defaults/defaultconfig.go +++ b/services/ocm/pkg/config/defaults/defaultconfig.go @@ -166,8 +166,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.GRPC.TLS = structs.CopyOrZeroValue(cfg.Commons.GRPCServiceTLS) } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/storage-users/pkg/config/defaults/defaultconfig.go b/services/storage-users/pkg/config/defaults/defaultconfig.go index a08134ec3..f165fbdc5 100644 --- a/services/storage-users/pkg/config/defaults/defaultconfig.go +++ b/services/storage-users/pkg/config/defaults/defaultconfig.go @@ -209,8 +209,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.Tasks.PurgeTrashBin.UserID = cfg.Commons.AdminUserID } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/web/pkg/config/defaults/defaultconfig.go b/services/web/pkg/config/defaults/defaultconfig.go index ebf9bad92..a0572fae3 100644 --- a/services/web/pkg/config/defaults/defaultconfig.go +++ b/services/web/pkg/config/defaults/defaultconfig.go @@ -174,8 +174,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } } diff --git a/services/webfinger/pkg/config/defaults/defaultconfig.go b/services/webfinger/pkg/config/defaults/defaultconfig.go index 53b2b8467..02d823d06 100644 --- a/services/webfinger/pkg/config/defaults/defaultconfig.go +++ b/services/webfinger/pkg/config/defaults/defaultconfig.go @@ -83,8 +83,10 @@ func EnsureDefaults(cfg *config.Config) { cfg.HTTP.TLS = cfg.Commons.HTTPServiceTLS } - if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && (cfg.HTTP.CORS.AllowedOrigins == nil && cfg.Commons != nil && cfg.Commons.OcisURL != "" || - len(cfg.HTTP.CORS.AllowedOrigins) == 1 && cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { + if (cfg.Commons != nil && cfg.Commons.OcisURL != "") && + (cfg.HTTP.CORS.AllowedOrigins == nil || + len(cfg.HTTP.CORS.AllowedOrigins) == 1 && + cfg.HTTP.CORS.AllowedOrigins[0] == "https://localhost:9200") { cfg.HTTP.CORS.AllowedOrigins = []string{cfg.Commons.OcisURL} } }