Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Fix CE Extensions deletion#1390

Merged
tzununbekov merged 1 commit into
mainfrom
transform-ce-extensions
Apr 11, 2023
Merged

Fix CE Extensions deletion#1390
tzununbekov merged 1 commit into
mainfrom
transform-ce-extensions

Conversation

@tzununbekov

Copy link
Copy Markdown
Member

CE Context transformation re-used the original context variable during the process, therefore deletion operation was ineffective because the end result still had all original keys.

Resolves #1386

@tzununbekov tzununbekov requested a review from a team April 11, 2023 13:47
@tzununbekov tzununbekov self-assigned this Apr 11, 2023
@tzununbekov tzununbekov merged commit 7f6f430 into main Apr 11, 2023
@tzununbekov tzununbekov deleted the transform-ce-extensions branch April 11, 2023 14:12
@jmcx

jmcx commented May 12, 2023

Copy link
Copy Markdown
Contributor

Hey @tzununbekov I'm trying to test this out while writing the docs for it. Looking at the merge date and the 1.24.4 release date, I was thinking this should be available in the patch. So I've updated my components version:

% tmctl config get
context: triggermesh
schemaRegistry: https://registry.staging.triggermesh.io
triggermesh:
    version: v1.24.4
    broker:
        version: v1.2.1
        memory:
            buffer-size: "100"
            produce-timeout: 1s
docker:
    timeout: 5s

and wrote a transformation:

context:
  - operation: delete
    paths:
    - key: Extensions
  - operation: add
    paths:
    - key: source
      value: mycustomsourcevalue

The change to the "source" attribute is working, but I'm still seeing the extension.

Curl into a CloudEvent source:

curl "http://localhost:54590" \                  
  -H "Ce-Specversion: 1.0" \
  -H "Ce-Type: mytype" \
  -H "Ce-Source: curl.shell" \
  -H "Ce-MyAttribute: my value" \
  -H "Content-Type: application/json" \
  -H "Ce-Id: 1234-abcd-x" \
  -d '{"Hello":"world"}'

output in watch:

☁️  cloudevents.Event
Context Attributes,
  specversion: 1.0
  type: mytype
  source: curl.shell
  id: 1234-abcd-x
  time: 2023-05-12T10:02:57.795670629Z
  datacontenttype: application/json
Extensions,
  myattribute: my value
Data,
  {
    "Hello": "world"
  }
☁️  cloudevents.Event
Context Attributes,
  specversion: 1.0
  type: triggermesh-transformation.output
  source: mycustomsourcevalue
  id: 1234-abcd-x
  time: 2023-05-12T10:02:57.795670629Z
  datacontenttype: application/json
Extensions,
  myattribute: my value
Data,
  {
    "Hello": "world"
  }

Do you think I'm not using the right version of the JSON transformation with the fix in it?

Here is the PR for the docs in parallel: triggermesh/docs#373

@tzununbekov

Copy link
Copy Markdown
Member Author
context:
  - operation: delete
    paths:
    - key: Extensions

I don't think this is a valid command. Try to delete the particular extension, not just "extensions".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support deleting CloudEvents extension attributes with the JSON Transformation

3 participants