-
Notifications
You must be signed in to change notification settings - Fork 41
feat(contracts): support multi-format #1239
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
javirln
left a comment
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.
LGTM
jiparis
left a comment
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.
Looks good. Only two minor comments.
| return nil, err | ||
| } | ||
|
|
||
| contract, err = biz.SchemaToRawContract(schema) |
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 guess in this case we always return JSON because raw format it's still not known.
| // Scenario 1: contracts that have been stored (and not updated) before the introduction of the raw_body field will have an empty raw_body | ||
| // so we will generate a json representation of the contract to populate the raw_body field in that case | ||
| // that way clients can always expect a raw_body field to be present | ||
| if len(contract.Raw) == 0 { |
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 know it's the same, but I would put here len(w.RawBody), just to keep consistency with the else if below.
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
Signed-off-by: Miguel <miguel@chainloop.dev>
b7d735c to
2401475
Compare
This PR allows users to manage contracts in different formats during the whole lifecycle #1237
In practice, for the user, this means that the system will preserve the contracts in the format (preserving even comments and ordering). It also improves the validation errors, moves them server-side, and improves error messaging.
Multi-format support
For example, creating a contract pointing to a yaml file now will maintain that format
the API also returns the detected format, this is a hint to help future clients of this API render the contacts
of course we can update the format at any time, let's move it to json

or cue
Validations
Validations have been moved to the server side and especially improved in the case of a yaml file by introducing protoyaml-go. Fixes #995
See below a contract that has errors and how it indicates the line and column where the error happens.
On the technical side, this patch.
raw_contractandcontract_formatthat store the raw content and format of the contract, respectively. Thebodycolumn that until today stored the binary representation of the proto will not be populated anymore,Closes #1237