-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[confmap] Automatically invoke Validate()
during Conf.Unmarshal
#12031
base: main
Are you sure you want to change the base?
[confmap] Automatically invoke Validate()
during Conf.Unmarshal
#12031
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12031 +/- ##
==========================================
- Coverage 91.68% 91.66% -0.02%
==========================================
Files 455 455
Lines 24053 24099 +46
==========================================
+ Hits 22052 22091 +39
- Misses 1629 1634 +5
- Partials 372 374 +2 ☔ View full report in Codecov by Sentry. |
There are some problems with this design, because the "validation" chain may be broken by custom "Unmarshaler" implementations which can lead to invalid configs being used:
Other problems can be if config is initially unmarshalled in a map then moved to the struct, etc. To prove this works, we need lots of tests for lots of different usage patterns. |
@bogdandrutu I was able to test the custom unmarshal scenario with the otlp receiver and confirmed it works since the custom unmarshal implementation invokes If the custom unmarshaller does not invoked I've added a tests to demonstrate these 2 scenarios. |
Description
Duplicate
component.ConfigValidator
intoconfmap
. Add capability forConfigValidator.Validate
to be invoked as part of unmarshal. Add a newUnmarshalOption
to allow controlling if validation is invoked.If we like this feature, we'll need to do some refactoring to how
otelcol
unmarshals if we want to take advantage of it. See #11524 (comment). After implementing it I'm still not convinced this solution is better than what we already have.Link to tracking issue
Related to #11524
Testing
Added new unit tests. Tested manually using local build.
Documentation
Added godoc comments.