Example command:
http localhost:5005/api/v1.0/validate-gating-yaml \ < ../greenwave-policies/fedora.yaml
Since you updated the API it would be nice to add some doc about it.
I like it! +1
rebased onto 5b8ffa7b8543bcc1b8310444117a3c823882a448
rebased onto 059c5a2bec33276291e9888ba4653e4134040cc4
I changed the YAML validation code completely but I had to create another class for policies in gating.yaml file. I have to think about this more, there is probably nicer solution.
gating.yaml
2 new commits added
Provide UI for validating gating.yaml
Make YAML parsing type safe
I wonder if it would be simpler/nicer to provide a CLI tool which can validate the policies?
On the server side we might then only need to add some API like "list all valid subject types" and "list all valid decision contexts" and then CLI tool would use that info to perform its checks.
It might be nice if people can use it as part of their CI workflow, to help prevent merging an invalid gating.yaml file in the first place.
Server already knows how to parse and validate YAML file. Having this functionality in a separate would mean to duplicate some code or separate the code for new package/subpackage.
Another problem is that the CLI package can get outdated.
I would prefer to validate even the attributes and tags in YAML.
A POST request can verify the YAML file. Maybe it would be nicer to return HTTP 400 if file is invalid.
rebased onto a9d3bb64a0edb5a00954478981d2adf7d74d544a
I'll drop the UI (we can add it later if needed) and work on the new API endpoint which will probably used soon.
Need to write test and if possible use !Policy and not some new tag (I'm currently using !RemotePolicy to make the verification be able to differentiate between policies set in configuration and remotely).
!Policy
!RemotePolicy
rebased onto b3be8705b8f1c3ef17185dbdd393c0e4cfd651ba
Updated.
Provide API for validating gating.yaml
Make YAML parsing type-safe
I tried that... and I if do this request:
curl -d "@example-gating.yaml" -X POST localhost:5005/api/v1.0/validate-gating-yaml
where example-gating.yaml is:
--- !Policy id: "testing_test" product_versions: - fedora-26 decision_context: bodhi_update_push_testing blacklist: [] rules: - !PassingTestCaseRule {test_case_name: dist.depcheck}
I get an error:
{ "message": "Missing !Policy tag" }
Am I doing something wrong?
Works when using --data-binary instead -d.
--data-binary
-d
Cool, +1
Pull-Request has been merged by lholecek
Example command: