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
+24
View File
@@ -201,6 +201,30 @@ storage:
So(err, ShouldBeNil)
})
Convey("Test verify config with invalid log level", t, func(c C) {
content := `{"distSpecVersion":"1.1.1","storage":{"rootDirectory":"/tmp/zot"},
"http":{"address":"127.0.0.1","port":"8080","realm":"zot"},
"log":{"level":"invalid"}}`
tmpfile := MakeTempFileWithContent(t, "zot-test.json", content)
os.Args = []string{"cli_test", "verify", tmpfile}
err := cli.NewServerRootCmd().Execute()
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "invalid log level")
So(err.Error(), ShouldContainSubstring, "invalid")
})
Convey("Test verify config with valid trace log level", t, func(c C) {
content := `{"distSpecVersion":"1.1.1","storage":{"rootDirectory":"/tmp/zot"},
"http":{"address":"127.0.0.1","port":"8080","realm":"zot"},
"log":{"level":"trace"}}`
tmpfile := MakeTempFileWithContent(t, "zot-test.json", content)
os.Args = []string{"cli_test", "verify", tmpfile}
err := cli.NewServerRootCmd().Execute()
So(err, ShouldBeNil)
})
Convey("Test verify CVE warn for remote storage", t, func(c C) {
content := `{
"storage":{