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

Add new MergeJsonKeys functionality to transformation filter. #350

Merged
merged 17 commits into from
Jul 25, 2024

Conversation

EItanya
Copy link
Member

@EItanya EItanya commented Jul 3, 2024

Add a new feature to the inja_transformer called MergeJsonKeys which allows merging of rendered templates into the JSON body without needing to rewrite the entire body

// prepare variables for non-advanced_templates_ scenario
absl::string_view name_to_split;
json* current = nullptr;
// if (!advanced_templates_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't end up supporting json pointer templates, I think we should keep this check in and throw in the constructor at config time

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to understand better what would be entailed, I honestly don't really know the different 🙈

Copy link
Contributor

Choose a reason for hiding this comment

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

It's largely just handling of / and ~

spec: https://datatracker.ietf.org/doc/html/rfc6901

our fork to re-introduce support in inja: solo-io/inja#6

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm now throwing an exception at config time

@EItanya EItanya marked this pull request as ready for review July 18, 2024 13:30
@solo-changelog-bot
Copy link

Issues linked to changelog:
#356

@nfuden
Copy link
Collaborator

nfuden commented Jul 18, 2024

lgtm pending yuval check

inja_template.set_text("\"{{header(\":path\")}}\"");
envoy::api::v2::filter::http::MergeJsonKeys_OverridableTemplate tmpl;
(*tmpl.mutable_tmpl()) = inja_template;
(*transformation.mutable_merge_json_keys()->mutable_json_keys())["ext2"] = tmpl;
Copy link
Member

Choose a reason for hiding this comment

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

please add tests for the dot logic. include edge cases to make sure we don't crash. i.e.

  • "foo.bar"
  • "foo..bar"
  • ".foo."
  • "..."
  • ".foo
  • "bar."

Copy link
Member

Choose a reason for hiding this comment

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

also empty string?

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed offline, I am going to remove this ability for now as it's not necessary. In order to ensure we can potentially add it back later I will throw an exception at config_time if a "." is present in the key

@soloio-bulldozer soloio-bulldozer bot merged commit f0c260f into main Jul 25, 2024
4 checks passed
@soloio-bulldozer soloio-bulldozer bot deleted the eitanya/hits_addend branch July 25, 2024 11:50
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.

4 participants