Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): better configuration errors using viper.UnmarshalExact() #2050

Merged

Conversation

eusebiu-constantin-petu-dbk
Copy link
Collaborator

What type of PR is this?

Which issue does this PR fix:

What does this PR do / Why do we need it:

If an issue # is not available please add repro steps and logs showing the issue:

Testing done on this change:

Automation added to e2e:

Will this break upgrades or downgrades?

Does this PR introduce any user-facing change?:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@eusebiu-constantin-petu-dbk
Copy link
Collaborator Author

error before patch:

peusebiu@PEUSEBIU-FC130:~/zot$ ./bin/zot-linux-amd64 serve examples/config-policy.json 
panic: config: invalid config
 
goroutine 1 [running]:
zotregistry.io/zot/pkg/cli/server.newServeCmd.func1(0xc000df6300?, {0xc001293740, 0x1, 0x1?})
        zotregistry.io/zot/pkg/cli/server/root.go:50 +0x210
github.com/spf13/cobra.(*Command).execute(0xc000df6300, {0xc001293700, 0x1, 0x1})
        github.com/spf13/[email protected]/command.go:987 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0xc000df6000)
        github.com/spf13/[email protected]/command.go:1115 +0x425
github.com/spf13/cobra.(*Command).Execute(0xc0000061a0?)
        github.com/spf13/[email protected]/command.go:1039 +0x19
main.main()
        zotregistry.io/zot/cmd/zot/main.go:10 +0x1e

with this patch:

peusebiu@PEUSEBIU-FC130:~/zot$ ./bin/zot-linux-amd64 serve examples/config-policy.json 
{"level":"error","error":"1 error(s) decoding:\n\n* 'HTTP.accessControl' has invalid keys: grups","time":"2023-11-16T13:21:38+02:00","message":"error while unmarshaling new config"}
panic: 1 error(s) decoding:
 
* 'HTTP.accessControl' has invalid keys: grups
 
goroutine 1 [running]:
zotregistry.io/zot/pkg/cli/server.newServeCmd.func1(0xc000ca2c00?, {0xc001563a30, 0x1, 0x1?})
        zotregistry.io/zot/pkg/cli/server/root.go:50 +0x210
github.com/spf13/cobra.(*Command).execute(0xc000ca2c00, {0xc0015639e0, 0x1, 0x1})
        github.com/spf13/[email protected]/command.go:987 +0xa91
github.com/spf13/cobra.(*Command).ExecuteC(0xc000ca2900)
        github.com/spf13/[email protected]/command.go:1115 +0x425
github.com/spf13/cobra.(*Command).Execute(0xc0000061a0?)
        github.com/spf13/[email protected]/command.go:1039 +0x19
main.main()
        zotregistry.io/zot/cmd/zot/main.go:10 +0x1e
peusebiu@PEUSEBIU-FC130:~/zot$

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8dd06c6) 92.06% compared to head (ac5b83f) 92.03%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2050      +/-   ##
==========================================
- Coverage   92.06%   92.03%   -0.03%     
==========================================
  Files         164      164              
  Lines       27717    27717              
==========================================
- Hits        25517    25510       -7     
- Misses       1628     1634       +6     
- Partials      572      573       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@rchincha rchincha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@rchincha rchincha merged commit 60eaf7b into project-zot:main Nov 16, 2023
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants