-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow REST data sources to form bodies from input
This adds a new option to the REST data source driver to form a body from input. This will be marshaled as JSON or interpreted as a string, and will be used as the message body. This allows us to dynamically form the body in order to better support POST-based implementations like OSV. the new field is called `body_from_field`. The field *must* exist in the input parameters and must be marked as required or have an appropriate default. The field must also be a top-level parameter. Here's an example of a data source that uses it: ```yaml --- version: v1 type: data-source name: osv context: {} rest: def: query: # Supports templating based on RFC6570 endpoint: 'https://api.osv.dev/v1/query' parse: json method: POST body_obj_from_field: query input_schema: type: object properties: query: type: object properties: version: type: string package: type: object properties: ecosystem: type: string description: The ecosystem the dependency belongs to name: type: string description: The name of the dependency required: - query ``` Note in this case we do validation of all parameters that can be passed to the body. usage within a rego evaluation policy would look as follows: ``` ... reqparams := { "query": { "version": version, "package": { "name": name, "ecosystem": "PyPI" } } } out := minder.datasource.osv.query(reqparams) ... ``` Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
- Loading branch information
Showing
7 changed files
with
1,039 additions
and
872 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.