argo-events icon indicating copy to clipboard operation
argo-events copied to clipboard

CloudEvents compliance / id field

Open paveq opened this issue 3 years ago • 2 comments

When sending CloudEvents compliant events to webhook endpoint, they get wrapped into another CloudEvents container by the EventSource, and JSON that was sent by event generating systems gets put to body of that wrapper.

To Reproduce Steps to reproduce the behavior:

  1. Send CloudEvents compliant object to webhook endpoint, such as: kubectl run curl --rm -i --tty --restart='Never' --image curlimages/curl:latest -- -X POST -d '{"specversion" : "1.0","type" : "com.example.someevent","source" : "/mycontext","id" : "A234-1234-1234","time" : "2018-04-05T17:31:00Z","datacontenttype" : "text/xml","data" : "<much wow=\"xml\"/>"}' http:/eventsource-svc/mystuff

Expected behavior It is at least possible for event generating system to set some fields such as subject and id (and maybe type?) themselves. Current behaviour makes it difficult to use standard CloudEvents fields to implement request-reply pattern, where event generating system generates unique id, and then later listens back the events related to that id on another "topic"/type.

Alternatively if id is to be always generated by argo-events, it would be nice to return it to caller in the HTTP response on webhook event source.

Of course these fields could be set on the body, but this makes CloudEvents compliance bit moot point, if CloudEvents is only used internally by Argo-Events.

paveq avatar Jan 13 '21 22:01 paveq

Subject is already set to event name, which probably is enough. Main issue I think is that id cannot be given.

As idea, do you think webhook endpoint could support following "REST-api" style to allow event generating system to specify id in request path?

apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
  name: webhook
spec:
  webhook:
    environment.create:
      port: "12000"
      endpoint: /environment/create/{id}
      method: POST

Might be possible to extend into generic endpoint where all parameters can be given in the url path, like this:

apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
  name: webhook
spec:
  webhook:
    port: "12000"
    endpoint: /{source}/{subject}/{id}
    method: POST

paveq avatar Jan 14 '21 07:01 paveq

This issue has been automatically marked as stale because it has not had any activity in the last 60 days. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 16 '21 02:03 github-actions[bot]