From eb8f61d1c17e1b814a9b3913eea5fe894d644718 Mon Sep 17 00:00:00 2001 From: Silvan Date: Mon, 10 Jun 2024 11:46:28 +0200 Subject: [PATCH] fix: read correct defaults (#8090) # Which Problems Are Solved Corrects reading of default configuration, despite reading all default configs only required defaults are read. # How the Problems Are Solved Reading the defualt config of the `mirror`-command was moved to a pre-run step of the command instead of doing it during initialization of the executable. # Additional Context - Closes https://github.com/zitadel/zitadel/issues/8059 - https://discord.com/channels/927474939156643850/1248594307267559535 (cherry picked from commit 7d852ad0dfdb7fe98486c31faaf001f4a25b56fa) --- cmd/mirror/mirror.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/mirror/mirror.go b/cmd/mirror/mirror.go index 3e4902ca7d..69e830658a 100644 --- a/cmd/mirror/mirror.go +++ b/cmd/mirror/mirror.go @@ -34,6 +34,10 @@ Order of execution: 3. mirror event store tables 4. recompute projections 5. verify`, + PersistentPreRun: func(cmd *cobra.Command, args []string) { + err := viper.MergeConfig(bytes.NewBuffer(defaultConfig)) + logging.OnError(err).Fatal("unable to read default config") + }, Run: func(cmd *cobra.Command, args []string) { config := mustNewMigrationConfig(viper.GetViper()) projectionConfig := mustNewProjectionsConfig(viper.GetViper()) @@ -59,9 +63,6 @@ Order of execution: The flag should be provided if you want to execute the mirror command multiple times so that the static data are also mirrored to prevent inconsistent states.`) migrateProjectionsFlags(cmd) - err := viper.MergeConfig(bytes.NewBuffer(defaultConfig)) - logging.OnError(err).Fatal("unable to read default config") - cmd.AddCommand( eventstoreCmd(), systemCmd(),