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

[Filebeat] httpjson: Add replaceAll helper function #32365

Merged

Conversation

andrewkroh
Copy link
Member

@andrewkroh andrewkroh commented Jul 14, 2022

What does this PR do?

replaceAll returns a copy of the string s with all non-overlapping instances
of old replaced by new.

Note that the order of the arguments differs from Go's strings.ReplaceAll to
make pipelining more ergonomic. This allows s to be piped in because it is
the final argument. For example,

[[ "some value" | replaceAll "some" "my" ]] // == "my value"

Why is it important?

This gives a simple way to manipulate a string in a template. The use case is fixing an incorrectly formatted nextlink value that an API (Trend Micro Vision One) is returning for pagination.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Related issues

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jul 14, 2022
replaceAll returns a copy of the string s with all non-overlapping instances
of old replaced by new.

Note that the order of the arguments differs from Go's [strings.ReplaceAll] to
make pipelining more ergonomic. This allows s to be piped in because it is
the final argument. For example,

    [[ "some value" | replaceAll "some" "my" ]]  // == "my value"
@andrewkroh andrewkroh force-pushed the feature/fb/httpjson-replaceAll-func branch from c3fd0e6 to a740f93 Compare July 14, 2022 23:25
@andrewkroh andrewkroh marked this pull request as ready for review July 14, 2022 23:25
@andrewkroh andrewkroh requested a review from a team as a code owner July 14, 2022 23:25
@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jul 15, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-07-18T22:00:04.434+0000

  • Duration: 76 min 26 sec

Test stats 🧪

Test Results
Failed 0
Passed 2172
Skipped 166
Total 2338

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@andrewkroh andrewkroh merged commit 5d4d48c into elastic:main Jul 19, 2022
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
* sort helper functions

* httpjson: Add replaceAll helper function

replaceAll returns a copy of the string s with all non-overlapping instances
of old replaced by new.

Note that the order of the arguments differs from Go's [strings.ReplaceAll] to
make pipelining more ergonomic. This allows s to be piped in because it is
the final argument. For example,

    [[ "some value" | replaceAll "some" "my" ]]  // == "my value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants