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 <rodrigo.chiossi@intel.com>
This commit is contained in:
Rodrigo Chiossi
2018-07-26 10:28:22 -07:00
committed by tmarcu
parent 82513c2ed5
commit a5099994ed
2 changed files with 11 additions and 3 deletions
+4 -3
View File
@@ -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()
}
+7
View File
@@ -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)