-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(config): add Validators to ExportedConfigs and "config verify" command. #154
Conversation
Codecov Report
@@ Coverage Diff @@
## master #154 +/- ##
===========================================
+ Coverage 64.84% 80.16% +15.31%
===========================================
Files 77 90 +13
Lines 2677 3837 +1160
===========================================
+ Hits 1736 3076 +1340
+ Misses 793 547 -246
- Partials 148 214 +66
Continue to review full report at Codecov.
|
|
||
// Validator is a method to verify if config is valid. If it is not valid, the | ||
// returned error should contain a human readable description of why. | ||
type Validator func(data map[string]interface{}) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use type ConfigAccessor
as argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConfigAccessor is an interface. Data is data. Validation validates the data, not the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interfaces describe behavior, not data.
This PR allows each module to export a verification function. Once the configuration is loaded/reloaded, all verifications are run one by one. if an error is raised, the process will exit.