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

Type mappings transformation #1154

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

gregschohn
Copy link
Collaborator

Description

[Describe what this change achieves]

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)
  • Why these changes are required?
  • What is the old behavior before changes and new behavior after changes?

Issues Resolved

[List any issues this PR will resolve]

Is this a backport? If so, please add backport PR # and/or commits #

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…g w/ Jinjava.

Major things to figure out: 1) how to deal with compositing parts of jinja templates (maybe it's just snippets vended as resources and a user writes their own top-level template) and 2) how to suppress reading any part of the json body when only the headers need to be transformed to prevent parsing the json/ndjson for every request through the system (probably minor though since most setups will probably be doing full-transforms on the vast majority of data flowing).

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
… so that they can fit w/in the transformation ecosystems.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
This supports preparsing templates and loading default or specific versions.  Those features are likely now in flux to be replaced with a better UX.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
…ts of jinjava transforms (see 'is_enabled').

These changes will reduce the efficiency of this type of transform, but w/out it, it isn't clear how we'll utilize dynamic typing.  My hope is that template logic is small relative to documents - and compute is cheap, so these are good tradeoffs to make.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.65%. Comparing base (d7884e9) to head (4b32d42).
Report is 35 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1154      +/-   ##
============================================
- Coverage     80.74%   80.65%   -0.09%     
- Complexity     2924     3003      +79     
============================================
  Files           399      410      +11     
  Lines         14845    15293     +448     
  Branches       1007     1040      +33     
============================================
+ Hits          11986    12335     +349     
- Misses         2252     2329      +77     
- Partials        607      629      +22     
Flag Coverage Δ
gradle-test ?
python-test ?
unittests 80.65% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

…s after the templating...

That preserve splicing not only improves efficiency, it also lets us pass messages through a template that might have non-textual data, like the ByteBufs, etc.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
…macro by name and invoke it since jinjava can't deal with invoking macros with dynamic names.

There are some rough tests in place that don't fully work.  The original ambition was to allow a user to specify both a route and an action for a given map in a macro but since macros only output rendered content, they're not well-suited to chain complex data (like regex matches) between macros.  As such, there will be significant design changes to the jinja routing mechanisms.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
Switched out Google's re2j for Java's implementation.  I didn't realize that the java implementation is closer to python regexes and that re2j (which I had thought was closer to python).
Minor tweaks to the route jinja template to make it easier to read when it's invoked.
Switched the replayer template to use the route functionality, which is considerably easier to get one's head around.
TODO -
* I'd like to make the feature flag names the same as the macro name for the route when the feature flag name is omitted.
* The test cases for the type mappings sanitization need a lot of work.
* When indices are created that DO NOT use type mappings, we should handle those more gracefully.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
…gexes and the target index can be specified with backreferences.

Notice that there's no way to discard data with regexes like there is with the type mappings (and the static type mappings do yield to regexes when no match was found).
Other changes:
The regex capture filter now has a guava cache for compiled patterns.
When static and regex mappings are null, we'll use a default (.*), (.*) -> \1_\2 mapping.
Enhanced some tests to pick up more corner cases.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
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.

1 participant