-
Notifications
You must be signed in to change notification settings - Fork 7
Fix not to render optional fields when unset #55
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
de4afaf
Fix not to render optional fields when unset
46dcddc
Adding CDEvent validation with test data optional fields unset
d47f9f0
fixing linter issues and override hashCode
04a08a1
fixing linter issues
5320531
test validation with JsonNode
eb71d25
Undo changes as per master copy
ffe1f93
removed org.json from test
150084a
remove validation for JSON render and keep only for cloudevents binding
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"context": { | ||
"id": "123456789", | ||
"type": "dev.cdevents.pipelinerun.finished.0.1.0", | ||
"source": "http://dev.cdevents", | ||
"version": "0.1.2", | ||
"timestamp": "2023-05-24T11:17:06Z" | ||
}, | ||
"customData": { | ||
}, | ||
"customDataContentType": "application/json", | ||
"subject": { | ||
"id": "/dev/pipeline/run/subject", | ||
"type": "PIPELINERUN", | ||
"content": { | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"context": { | ||
"id": "dc0bf5f5-f2e4-44c3-b9a6-1f0cf51b050b", | ||
"type": "dev.cdevents.pipelinerun.queued.0.1.0", | ||
"source": "http://dev.cdevents", | ||
"version": "0.1.2", | ||
"timestamp": "2023-05-24T18:34:41Z" | ||
}, | ||
"customData": { | ||
}, | ||
"customDataContentType": "application/json", | ||
"subject": { | ||
"id": "/dev/pipeline/run/subject", | ||
"type": "PIPELINERUN", | ||
"content": { | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"context": { | ||
"id": "cbde772c-17ad-490d-aea0-41fb060d1483", | ||
"type": "dev.cdevents.pipelinerun.started.0.1.0", | ||
"source": "http://dev.cdevents", | ||
"version": "0.1.2", | ||
"timestamp": "2023-05-24T18:48:12Z" | ||
}, | ||
"customData": { | ||
}, | ||
"customDataContentType": "application/json", | ||
"subject": { | ||
"id": "/dev/pipeline/run/subject", | ||
"type": "PIPELINERUN", | ||
"content": { | ||
"pipelineName": "test-pipeline-started", | ||
"url": "http://dev/pipeline/url" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"context": { | ||
"id": "49e16403-c5b5-4e2a-9540-160787459a21", | ||
"type": "dev.cdevents.taskrun.finished.0.1.0", | ||
"source": "http://dev.cdevents", | ||
"version": "0.1.2", | ||
"timestamp": "2023-05-24T19:20:57Z" | ||
}, | ||
"customData": { | ||
}, | ||
"customDataContentType": "application/json", | ||
"subject": { | ||
"id": "/dev/task/run/subject", | ||
"type": "TASKRUN", | ||
"content": { | ||
"pipelineRun": { | ||
"id": "/dev/pipeline/run/subject" | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"context": { | ||
"id": "f75eb164-947c-4827-9036-9ec7fda38873", | ||
"type": "dev.cdevents.taskrun.started.0.1.0", | ||
"source": "http://dev.cdevents", | ||
"version": "0.1.2", | ||
"timestamp": "2023-05-24T19:16:11Z" | ||
}, | ||
"customData": { | ||
}, | ||
"customDataContentType": "application/json", | ||
"subject": { | ||
"id": "/dev/task/run/subject", | ||
"type": "TASKRUN", | ||
"content": { | ||
"pipelineRun": { | ||
"id": "/dev/pipeline/run/subject" | ||
} | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks - I think this is fine, perhaps in future, we might add a flag to make validation optional.
In the golang SDK I did not include validation in the JSON rendering, I made a
validate
method available instead, so that it is possible to render and invalid CDEvent to JSON, and the producer can decide whether to validate or not.I did include a call to
validate
in the cloudevents binding to enforce sending of valid events thought (similar to what you had before).I wonder whether instead of moving the validation from
cdEventAsCloudEvent
tocdEventAsJson
, it would be better to add a call tovalidate
in the test?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.
I'm also ok with keeping it as it is today.
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.
Agree, even this keeps the behavior consistent.
Reverting to keep the validation only for CloudEvents binding, removed for JSON render and added test assertion to validate CDEvent against schema.