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

[Good First Issues]: implement function "replace_between_delimiters" - 7 points #421

Closed
Tracked by #355
Michaelg22 opened this issue Feb 10, 2023 · 3 comments · Fixed by #434
Closed
Tracked by #355

[Good First Issues]: implement function "replace_between_delimiters" - 7 points #421

Michaelg22 opened this issue Feb 10, 2023 · 3 comments · Fixed by #434
Assignees
Labels
good first issue help-wanted Extra attention is needed

Comments

@Michaelg22
Copy link
Contributor

Michaelg22 commented Feb 10, 2023

Motivation

Vanus Functions are a series of pre-built functions worked within Vanus transformer. By choosing a function, users can specify the way that events will be changed.

It will be a good start if you decide to contribute to Vanus codes.

Details

This function is used to replace the characters between two delimiters with user-specified text of an existing json element.

Description

Function name: replace_between_delimiters

Function description:

Replaces the characters between two delimiters with user-specified text.
Enter any character, including a space.

must have - startDelimiter - endDelimiter.

Example

For example, if delimiters are && and &&

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data" : {
        "info : "this is &&jay ding&&",
        "appinfoB" : 123,
        "appinfoC" : true
    }
}

After the function "replace_between_delimiters":

"pipeline":[
    {"command":["replace_between_delimiters","$.data.appinfoA", "&&", "&&", "michael"]}
]

The transformed event should look like:

{
    "specversion" : "1.0",
    "type" : "com.example.someevent",
    "source" : "/mycontext",
    "subject": null,
    "id" : "C234-1234-1234",
    "time" : "2018-04-05T17:31:00Z",
    "comexampleextension1" : "value",
    "comexampleothervalue" : 5,
    "datacontenttype" : "application/json",
    "data" : {
        "info : "this is &&michael&&",
        "appinfoB" : 123,
        "appinfoC" : true
    }
}

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-replace_between_delimiters
  3. Create replace_between_delimiters.go under internal/primitive/transform/action/strings, and then implement the function.
  4. Create replace_between_delimiters_test.go under internal/primitive/transform/action/strings for unit test.
  5. Register your function in internal/primitive/transform/runtime/init.go.
  6. Submit your PR

Contribution points

Each issue counts specific points based on its difficulty. Contributors earn the corresponding points if they solve that issue. Contribution points are used to describe the contributions contributors have made. They can also be used to get rewards when there are community events.

This issue counts 5 points.

How to claim to solve the issue

If you want to implement this function, please leave a comment in this issue like:

I'd like to implement this function, please assign this issue to me.

Vanus community will assign the issue to you on time.

@Michaelg22 Michaelg22 changed the title [Good First Issues]: implement function "replace_between_delimiters" - 5 points [Good First Issues]: implement function "replace_between_delimiters" - 7 points Feb 10, 2023
@Michaelg22 Michaelg22 added good-first-issue Good for newcomers help-wanted Extra attention is needed good first issue and removed good-first-issue Good for newcomers labels Feb 10, 2023
@c0d33ngr
Copy link
Contributor

Please assign this to me, I'd love to work on this

@Michaelg22
Copy link
Contributor Author

@c0d33ngr how is it going?

@c0d33ngr
Copy link
Contributor

It's going well, I'm using strings.Split(), I'll make PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue help-wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants