-
Notifications
You must be signed in to change notification settings - Fork 10
Add support for jsonschemas #6
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
Add the ability to generate jsonschemas from the golang structs. Generate jsonschemas for existing events, and use them to validate test data in JSON format. Signed-off-by: Andrea Frittoli <[email protected]>
|
This mostly works well, there is only one issue to solve on the validation side. Right now when doing validate the type of CDEvent object does not match what the validator expects for some reason. A trick is to marshal the CDEvent to json, unmarshal it back using a generic |
Add initial jsonschemas for some of the events: - taskrun - pipelinerun - change These json schemas are automatically generated through the go types defined in the new cdevents/go-sdk, using the library github.com/invopop/jsonschema, see cdevents/sdk-go#6 for details. Signed-off-by: Andrea Frittoli <[email protected]>
Producing a cloudevent or json does not require changing the event, so using the reader interface instead. Signed-off-by: Andrea Frittoli <[email protected]>
The omitempty struct tag is interpreted by the schema generation library like a non-required field, so we cannot set "omitempty" on required fields, else the schema will be invalid. To solve the issue, use instead minLenght tags for all string required fields, to indicate that a non-empty value must be provided for validation to pass. Signed-off-by: Andrea Frittoli <[email protected]>
|
Found a solution in using |
Add initial jsonschemas for some of the events: - taskrun - pipelinerun - change These json schemas are automatically generated through the go types defined in the new cdevents/go-sdk, using the library github.com/invopop/jsonschema, see cdevents/sdk-go#6 for details. Signed-off-by: Andrea Frittoli <[email protected]>
Add initial jsonschemas for all of the events. These json schemas are automatically generated through the go types defined in the new cdevents/go-sdk, using the library github.com/invopop/jsonschema, see cdevents/sdk-go#6 for details. Signed-off-by: Andrea Frittoli <[email protected]>
Add initial jsonschemas for all of the events. These json schemas are automatically generated through the go types defined in the new cdevents/go-sdk, using the library github.com/invopop/jsonschema, see cdevents/sdk-go#6 for details. Signed-off-by: Andrea Frittoli <[email protected]>
* Add jsonschema for a few of the events Add initial jsonschemas for all of the events. These json schemas are automatically generated through the go types defined in the new cdevents/go-sdk, using the library github.com/invopop/jsonschema, see cdevents/sdk-go#6 for details. Signed-off-by: Andrea Frittoli <[email protected]>
Add the ability to generate jsonschemas from the golang structs.
Generate jsonschemas for existing events, and use them to validate
test data in JSON format.
Signed-off-by: Andrea Frittoli [email protected]