mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-06 05:31:50 +00:00
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:
+4
-3
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user