From a5099994ed1588765211dfbf96fb74756c8aa2a9 Mon Sep 17 00:00:00 2001 From: Rodrigo Chiossi Date: Wed, 25 Jul 2018 18:30:20 +0000 Subject: [PATCH] config: Set config version on conversion The old INI config does not have versioning, so when performing a conversion, it needs to be set. Also, since now the config format is identified on parsing, there is no need to force Old Config when starting the conversion. This allows the convert command to also convert between different TOML versions Signed-off-by: Rodrigo Chiossi --- config/config.go | 7 ++++--- mixer/cmd/config.go | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config/config.go b/config/config.go index 606cf82..e6c3ecb 100644 --- a/config/config.go +++ b/config/config.go @@ -449,8 +449,6 @@ func (config *MixConfig) Convert(filename string) error { return err } - // Force UseNewConfig to false - UseNewConfig = false if err := config.Parse(); err != nil { return err } @@ -459,9 +457,12 @@ func (config *MixConfig) Convert(filename string) error { return err } - // Force UseNewConfig to true + // Make sure the converted config is in the New Format UseNewConfig = true + // Set config to the current format + config.version = CurrentConfigVersion + return config.SaveConfig() } diff --git a/mixer/cmd/config.go b/mixer/cmd/config.go index 7d02453..43527a0 100644 --- a/mixer/cmd/config.go +++ b/mixer/cmd/config.go @@ -51,6 +51,13 @@ var configConvertCmd = &cobra.Command{ a backup file of the old config and will replace it with the converted one. Environment variables will not be expanded and the values will not be validated`, Run: func(cmd *cobra.Command, args []string) { + /* If no state file exists, it must be created first to ensure the FORMAT value + is transferred from old configs before conversion */ + var ms config.MixState + if err := ms.Load(); err != nil { + fail(err) + } + var mc config.MixConfig if err := mc.Convert(configFile); err != nil { fail(err)