mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
Target for cheking not commited config files.
Signed-off-by: laurentiuNiculae <themelopeus@gmail.com> Separated updateDistSpec functionality Removed rewriting of config when distSpecVersion was wrong
This commit is contained in:
committed by
Ramkumar Chinchani
parent
efc55b013e
commit
0d4cc8736d
+17
-15
@@ -354,24 +354,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
|
||||
if !config.Storage.GC && viperInstance.Get("storage::gcdelay") == nil {
|
||||
config.Storage.GCDelay = 0
|
||||
}
|
||||
}
|
||||
|
||||
func updateDistSpecVersion(config *config.Config) {
|
||||
if config.DistSpecVersion == distspec.Version {
|
||||
return
|
||||
}
|
||||
|
||||
log.Warn().
|
||||
Msgf("config dist-spec version: %s differs from version actually used: %s",
|
||||
config.DistSpecVersion, distspec.Version)
|
||||
|
||||
config.DistSpecVersion = distspec.Version
|
||||
}
|
||||
|
||||
func LoadConfiguration(config *config.Config, configPath string) error {
|
||||
// Default is dot (.) but because we allow glob patterns in authz
|
||||
// we need another key delimiter.
|
||||
@@ -413,5 +412,8 @@ func LoadConfiguration(config *config.Config, configPath string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// update distSpecVersion
|
||||
updateDistSpecVersion(config)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user