Update dist-spec version automatically

Warning if config has wrong dist-spec version

Signed-off-by: laurentiuNiculae <themelopeus@gmail.com>
This commit is contained in:
laurentiuNiculae
2022-03-07 14:50:15 +02:00
committed by Ramkumar Chinchani
parent fa27e22404
commit 63d94d4ac5
25 changed files with 108 additions and 40 deletions
+17
View File
@@ -363,6 +363,23 @@ func applyDefaultValues(config *config.Config, viperInstance *viper.Viper) {
}
}
}
if config.DistSpecVersion != distspec.Version {
log.Warn().Err(errors.ErrBadConfig).
Msgf("config dist-spec version: %s differs from version actually used: %s, will be corrected automatically",
config.DistSpecVersion, distspec.Version)
// rewrite the config file
viperInstance.Set("distSpecVersion", distspec.Version)
err := viperInstance.WriteConfig()
if err != nil {
log.Warn().Err(errors.ErrBadConfig).
Msg("can't rewrite the config file")
}
config.DistSpecVersion = distspec.Version
}
}
func LoadConfiguration(config *config.Config, configPath string) {