From 661c0211de55b88c8184f287a47b8a900d9e1e33 Mon Sep 17 00:00:00 2001 From: Christian Munklinde Leth-Espensen Date: Fri, 17 May 2024 15:17:31 +0200 Subject: [PATCH] :wrench: Migrate deprecated git cluster fields to the new ones if set --- pkg/api/config/v1alpha1/platform_config_types.go | 15 +++++++++++++++ pkg/service/config/config.go | 2 ++ 2 files changed, 17 insertions(+) diff --git a/pkg/api/config/v1alpha1/platform_config_types.go b/pkg/api/config/v1alpha1/platform_config_types.go index f0e429182..0d75cbedc 100644 --- a/pkg/api/config/v1alpha1/platform_config_types.go +++ b/pkg/api/config/v1alpha1/platform_config_types.go @@ -505,3 +505,18 @@ func (g ClusterGit) validate(path *field.Path) field.ErrorList { return errs } + +func (cfg *PlatformConfig) Migrate() { + for _, c := range cfg.Clusters { + if c.Git.URL != "" { + cfg.Client.Git.Auths = append(cfg.Client.Git.Auths, GitAuth{ + URL: c.Git.URL, + Credentials: c.Git.Credentials, + }) + } + if cfg.Client.Git.Author.Name == "" { + cfg.Client.Git.Author.Name = c.Git.Author.Name + cfg.Client.Git.Author.Email = c.Git.Author.Email + } + } +} diff --git a/pkg/service/config/config.go b/pkg/service/config/config.go index 4b48ede44..2a3667b4b 100644 --- a/pkg/service/config/config.go +++ b/pkg/service/config/config.go @@ -112,6 +112,8 @@ func (b *serviceBuilder) build() (*service, error) { if err != nil { return nil, fmt.Errorf("could not merge env config: %w", err) } + b.pCFG.Migrate() + b.oCFG.Default() return &service{oCFG: b.oCFG, pCFG: b.pCFG}, nil