mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-20 15:31:14 -06:00
63e1877c48
This commit adds a config for yamllint, mass-reformats all of the existing Yaml testcases to pass linting, and adds a Yaml linting job to the pull-request Github Actions workflow. A few careful exceptions and ignores were added to the linter's config to allow keeping our existing Yaml files with minimal reformatting. Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
50 lines
1.3 KiB
YAML
50 lines
1.3 KiB
YAML
---
|
|
cases:
|
|
- note: rendertemplate/simple
|
|
query: data.test.p = x
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
template_string = `{{.test}}`
|
|
template_vars = {`test`: `hello world`}
|
|
p = strings.render_template(template_string, template_vars)
|
|
want_result:
|
|
- x: "hello world"
|
|
|
|
- note: rendertemplate/simpleint
|
|
query: data.test.p = x
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
template_string = `{{.test}}`
|
|
template_vars = {`test`: 2023}
|
|
p = strings.render_template(template_string, template_vars)
|
|
want_result:
|
|
- x: "2023"
|
|
|
|
- note: rendertemplate/complex
|
|
query: data.test.p = x
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
template_string = `{{range $i, $name := .hellonames}}{{if $i}},{{end}}hello {{$name}}{{end}}`
|
|
template_vars = {`hellonames`: [`rohan`, `john doe`]}
|
|
p = strings.render_template(template_string, template_vars)
|
|
want_result:
|
|
- x: "hello rohan,hello john doe"
|
|
|
|
- note: rendertemplate/missingkey
|
|
query: data.test.p = x
|
|
modules:
|
|
- |
|
|
package test
|
|
|
|
template_string = `{{.testvarnotprovided}}`
|
|
template_vars = {`test`: `hello world`}
|
|
p = strings.render_template(template_string, template_vars)
|
|
want_error_code: eval_builtin_error
|
|
strict_error: true
|