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 "duplicate" - 5 points #372

Closed
Tracked by #355
JieDing opened this issue Dec 29, 2022 · 5 comments · Fixed by #392
Closed
Tracked by #355

[Good First Issues]: implement function "duplicate" - 5 points #372

JieDing opened this issue Dec 29, 2022 · 5 comments · Fixed by #392
Assignees
Labels
good first issue help-wanted Extra attention is needed

Comments

@JieDing
Copy link
Contributor

JieDing commented Dec 29, 2022

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 copy the value of an existed json element, and create a new json element with that value.

Description

Function name: duplicate

Function args:

  • sourcePath: the json path of the existed object.
  • targetPath: the json path of the new object.

Function description: Copy the value of an existed json element, and create a new json element with that value. Both elements with the same value exist after this function.

Example

For example, if users' original event looks 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" : "abc",
        "appinfoB" : 123,
        "appinfoC" : true
    }
}

After the function "duplicate":

"pipeline":[
    {"command":["duplicate","$.data.appinfoA","$.data.appinfoD"]}
]

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" : {
        "appinfoA" : "abc",
        "appinfoB" : 123,
        "appinfoC" : true,
        "appinfoD" : "abc"
    }
}

How to implement

  1. Fork the vanus repository.
  2. Create a branch function-duplicate
  3. Create duplicate.go under internal/primitive/transform/action/structs, and then implement the function.
  4. Create duplicate_test.go under internal/primitive/transform/action/structs 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.

@n-kurasawa
Copy link
Contributor

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

@n-kurasawa
Copy link
Contributor

I get a 404 error when I try to do "Sign the CLA" in CONTRIBUTING.md.
What should I do?

2023-01-02.7.39.14.mov

@JieDing
Copy link
Contributor Author

JieDing commented Jan 3, 2023

I get a 404 error when I try to do "Sign the CLA" in CONTRIBUTING.md. What should I do?

2023-01-02.7.39.14.mov

Hi @n-kurasawa thanks for being interested in Vanus. I just update the link of signing our CLA. Please try it again and let me know if there is anything wrong again.

@n-kurasawa
Copy link
Contributor

@JieDing
Thank you.
I was able to sign the CLA.

May I work on this issue?

@JieDing
Copy link
Contributor Author

JieDing commented Jan 3, 2023

@JieDing Thank you. I was able to sign the CLA.

May I work on this issue?

sure

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