-
Notifications
You must be signed in to change notification settings - Fork 61
Update CloudEvent generation to replace data
instead of deep merge
#144
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
Conversation
`CloudEvent.data` is defined as an arbitrary payload. For some CloudEvents it may be a string, for others it may be an object. Theres a few special cases that need to be handled with data: * eventarc - initially returns `data` as JSON, it can be returned as a primitive * pubsub - `data.message.json` should be an opaque value
be7bbfb
to
4c72b0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the behavior as is except for when we know the schema is a map. In cases where something is logically a map of string to string we can say that overriding anything in that map overrides the whole map. So for example, setting content type on a storage object still leaves content size present, but overriding a pubsub message's json
attribute overrides the whole json
.
Would that be something as simple as:
Or is there something bigger I am overlooking? |
At least that's how I'd do it if I wanted to solve it generically. Otherwise you can do piecemeal overrides everywhere. This would solve
|
* Update to README.md to include more samples to get started
Storage CloudEvents contain a "bucket" field. The mock data should return this "bucket" field to accurately reflect live data. [More info here](https://github.com/firebase/firebase-functions/blob/27a49837ea7b74d9d2926e74c387f45704d57889/src/v2/providers/storage.ts#L185)
... But I'm not convinced this is the best approach.
Closing this PR in favor of #146 |
Description
CloudEvent.data
is defined as an arbitrary payload. For someCloudEvents it may be a string, for others it may be an object.
Theres a few special cases that need to be handled with data:
data
as JSON, it can be returned as a primitivedata.message.json
should be an opaque valueCode sample