fix: accept log levels supported by older zot versions, validate configured log level (#3639)

In zot config accept the same log levels as in https://github.com/rs/zerolog/blob/5391dd7c34c86c2a3b731cd3c3f1b252706e7925/globals.go#L37
This is to maintain backward compatibility with other zot version configurations.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2025-12-13 00:33:54 +02:00
committed by GitHub
parent 08fae9104d
commit 1447bb24b4
3 changed files with 41 additions and 7 deletions
+7
View File
@@ -1068,6 +1068,13 @@ func LoadConfiguration(config *config.Config, configPath string) error {
return err
}
// Validate log level before creating logger to avoid panic
if _, err := zlog.ParseLevel(config.Log.Level); err != nil {
logger.Error().Err(zerr.ErrBadConfig).Str("level", config.Log.Level).Msg(err.Error())
return err
}
log := zlog.NewLogger(config.Log.Level, config.Log.Output)
if len(metaData.Keys) == 0 {