mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 12:58:02 +08:00
refactor(zli): add typed ~/.zot config layer and strict validation (#4030)
feat(cli): add typed ~/.zot config layer and strict validation
Introduce pkg/cli/client/config.go with ZliConfigFile/ZliConfig and
ReadZliConfigFile, replacing the loose map[string]any load/save path in
config_cmd.go.
Parsing now rejects malformed JSON with ErrCliBadConfig and requires a
non-null configs array (ErrCliMissingConfigsField when wrapped). Each
profile must have non-empty _name and url.
Config commands delegate to typed helpers (Find, AddEntry, RemoveEntry,
GetVar/SetVar/ResetVar, FormatNames, WriteFile). Fresh or minimal files
still behave as empty via isFreshCliRead (ErrEmptyJSON or missing configs).
Tests: prefer t.Setenv("HOME", t.TempDir()) where CLI resolution uses --url
only; align CVE/client/search tests with mandatory profile URL and HOME
isolation.
Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
@@ -49,6 +49,7 @@ func GetDetails(err error) map[string]string {
|
||||
var (
|
||||
ErrBadConfig = errors.New("invalid server config")
|
||||
ErrCliBadConfig = errors.New("invalid cli config")
|
||||
ErrCliMissingConfigsField = errors.New(`missing or null "configs" field`)
|
||||
ErrRepoNotFound = errors.New("repository not found")
|
||||
ErrRepoBadVersion = errors.New("unsupported repository layout version")
|
||||
ErrRepoBadLayout = errors.New("invalid repository layout")
|
||||
|
||||
Reference in New Issue
Block a user