open-policy-agent / conftest

Write tests against structured configuration data using the Open Policy Agent Rego query language
https://conftest.dev
Other
2.88k stars 307 forks source link

Conftest fails on YAMLs with version #998

Open pstoeckle opened 2 months ago

pstoeckle commented 2 months ago

I wanted to check a YAML document with the YAML version in the preamble

%YAML 1.1
---
group_id: 1234

... using ...

conftest test --parser yaml test.yml

However, conftest fails stating

Error: running test: parse configurations: parser unmarshal: unmarshal multiple documents: unmarshal subdocument yaml: error converting YAML to JSON: yaml: line 1: did not find expected <document start>, path: test.yml

If I remove the preamble, it works.

jalseth commented 2 months ago

This is new to me, but a quick skim of the YAML 1.2 spec indicates this should be supported. Conftest is using sigs.k8s.io/yaml for its YAML parsing. Do you happen to know of any Golang YAML parsers that support this?

pstoeckle commented 2 months ago

Do you happen to know of any Golang YAML parsers that support this?

No, not really.

My fix was so far to simply remove the preamble ...