mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-24 09:15:31 -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>
103 lines
2.1 KiB
YAML
103 lines
2.1 KiB
YAML
---
|
|
cases:
|
|
- data:
|
|
networks:
|
|
- id: n1
|
|
public: false
|
|
- id: n2
|
|
public: false
|
|
- id: n3
|
|
public: true
|
|
ports:
|
|
- id: p1
|
|
networks:
|
|
- n1
|
|
- id: p2
|
|
networks:
|
|
- n3
|
|
- id: p3
|
|
networks:
|
|
- n2
|
|
servers:
|
|
- id: s1
|
|
name: app
|
|
ports:
|
|
- p1
|
|
- p2
|
|
- p3
|
|
protocols:
|
|
- https
|
|
- ssh
|
|
- id: s2
|
|
name: db
|
|
ports:
|
|
- p3
|
|
protocols:
|
|
- mysql
|
|
- id: s3
|
|
name: cache
|
|
ports:
|
|
- p3
|
|
protocols:
|
|
- memcache
|
|
- http
|
|
- id: s4
|
|
name: dev
|
|
ports:
|
|
- p1
|
|
- p2
|
|
protocols:
|
|
- http
|
|
input_term: "{}"
|
|
modules:
|
|
- |
|
|
package opa.example
|
|
|
|
public_servers[server] {
|
|
server = data.servers[_]
|
|
server.ports[_] = data.ports[i].id
|
|
data.ports[i].networks[_] = data.networks[j].id
|
|
data.networks[j].public = true
|
|
}
|
|
|
|
violations[server] {
|
|
server = data.servers[_]
|
|
server.protocols[_] = "http"
|
|
data.opa.example.public_servers[server]
|
|
}
|
|
- |
|
|
package topdown_test_partial
|
|
|
|
__result__ = _result {
|
|
_result = {{"id": "s4", "name": "dev", "ports": ["p1", "p2"], "protocols": ["http"]}}
|
|
}
|
|
note: example/both
|
|
query: data.opa.example = x
|
|
want_result:
|
|
- x:
|
|
public_servers:
|
|
- id: s1
|
|
name: app
|
|
ports:
|
|
- p1
|
|
- p2
|
|
- p3
|
|
protocols:
|
|
- https
|
|
- ssh
|
|
- id: s4
|
|
name: dev
|
|
ports:
|
|
- p1
|
|
- p2
|
|
protocols:
|
|
- http
|
|
violations:
|
|
- id: s4
|
|
name: dev
|
|
ports:
|
|
- p1
|
|
- p2
|
|
protocols:
|
|
- http
|