From 0ea3c5691f420fbb9644a9b2c7e5fc65aadebd3b Mon Sep 17 00:00:00 2001 From: Silvan Date: Thu, 18 Jul 2024 16:00:58 +0200 Subject: [PATCH] fix(mirror): read config correctly (#8330) # Which Problems Are Solved The mirror command read the configurations in the wrong order # How the Problems Are Solved The Pre execution run of `mirror` reads the default config first and then applies the custom configs --- cmd/mirror/mirror.go | 8 +++++++- cmd/zitadel.go | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/mirror/mirror.go b/cmd/mirror/mirror.go index 69e830658a..3fbfe1ae94 100644 --- a/cmd/mirror/mirror.go +++ b/cmd/mirror/mirror.go @@ -18,7 +18,7 @@ var ( shouldReplace bool ) -func New() *cobra.Command { +func New(configFiles *[]string) *cobra.Command { cmd := &cobra.Command{ Use: "mirror", Short: "mirrors all data of ZITADEL from one database to another", @@ -37,6 +37,12 @@ Order of execution: PersistentPreRun: func(cmd *cobra.Command, args []string) { err := viper.MergeConfig(bytes.NewBuffer(defaultConfig)) logging.OnError(err).Fatal("unable to read default config") + + for _, file := range *configFiles { + viper.SetConfigFile(file) + err := viper.MergeInConfig() + logging.WithFields("file", file).OnError(err).Warn("unable to read config file") + } }, Run: func(cmd *cobra.Command, args []string) { config := mustNewMigrationConfig(viper.GetViper()) diff --git a/cmd/zitadel.go b/cmd/zitadel.go index c855dd4495..b6d6e9c873 100644 --- a/cmd/zitadel.go +++ b/cmd/zitadel.go @@ -56,7 +56,7 @@ func New(out io.Writer, in io.Reader, args []string, server chan<- *start.Server start.New(server), start.NewStartFromInit(server), start.NewStartFromSetup(server), - mirror.New(), + mirror.New(&configFiles), key.New(), ready.New(), )