-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/ottl] Add new IsMap
and IsString
functions
#22750
[pkg/ottl] Add new IsMap
and IsString
functions
#22750
Conversation
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.
Overall I think this looks good, but as we discussed offline I think it would make sense to use the typed Getters to do the type checking in these functions so we have a single source of truth for type checks. We could have these functions take typed Getter parameters, then check whether the typed Getter returns an error. To distinguish type errors from other errors, typed Getters would return a TypeError
or similar error type that indicates an error is from a type mismatch.
6e220ae
to
29299b6
Compare
This reverts commit 386d53540e5d1bb1cc8d0e30cf1db47309460d57.
386d535
to
28205a8
Compare
…2750) * Add new functions * Add docs * changelog * fix lint * Switch to typed getters using typed errors * Use errors.As * Revert "Use errors.As" This reverts commit 386d53540e5d1bb1cc8d0e30cf1db47309460d57. * Ensure wrapped TypeErrors are returned * Add type check to tests * Added more tests * Use TypeError in tests to ensure the error is wrapped * Check that false is returned with error * Fix lint * Wrap errors in TypeLike getters
Description:
Adds new functions to facilitate type checking. Most useful when checking the type of a body to determine if it needs to be parsed or not.
Link to tracking Issue:
Closes #22161
Testing:
Added tests
Documentation:
Updated func readme