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 "check_custom_values" - 7 points #428

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

[Good First Issues]: implement function "check_custom_values" - 7 points #428

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

Comments

@Michaelg22
Copy link
Contributor

Michaelg22 commented Feb 13, 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

Function name: check_custom_values

Args

  • sourceJsonPath - The name of an existing column.
  • customValue - Custom value to check
  • targetJsonPath The name of the new column to be created.
  • trueFlagReplacement - custom string if value equal custom value
  • falseFlagReplacement - Custom string if value doesn't equal custom value

Description

The function is used to check if the source JSON path contains the customValue or not. If it contains that value, the trueFlagReplacement will be assigned to the target JSON path. If it doesn't, the falseFlagReplacement will be assigned to the target JSON path.

Example

{
    "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" : {
        "appinfoA" : "",
       

    }
}

After the function "check_custom_values":

"pipeline":[
    {"command":["extract_custom_values","$.data.appinfoA", "$.data.appinfoC", "The element has content.", "The element is empty"]}
]

The transformed event should look like this:

{
    "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" : {
        "appinfoA" : "",
        "appinfoC" : "The element is empty"

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-check_custom_values
  3. Create check_custom_values.go under internal/primitive/transform/action/strings, and then implement the function.
  4. Create check_custom_values .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 7 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 added help-wanted Extra attention is needed good first issue labels Feb 13, 2023
@dhanusaputra
Copy link
Contributor

would like to do this, please assign this issue to me thank you

@Michaelg22
Copy link
Contributor Author

Hi @dhanusaputra, Thanks for your interest in developing a function. Join our slack community for better communication.

@dhanusaputra
Copy link
Contributor

sure will join the slack, thank you

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