cloudbase / powershell-yaml

PowerShell CmdLets for YAML format manipulation
Apache License 2.0
434 stars 78 forks source link

Powershell-Yaml incorrectly errors on duplicate key #124

Closed derekwbrown closed 7 months ago

derekwbrown commented 7 months ago

I have the latest powershell-yaml installed. When reading https://github.com/DataDog/datadog-agent/blob/main/.gitlab-ci.yml

powershell-yaml throws a duplicate key error. This file is properly parsed by gitlab, yamllint.com, etc.

gabriel-samfira commented 7 months ago

Hi @derekwbrown

Try passing in the -UseMergingParser as an argument to ConvertFrom-Yaml

Example:

ConvertFrom-Yaml -UseMergingParser -Ordered (gc -raw ./.gitlab-ci.yml)

Please note, the merging parser does have some limitations as stated here:

https://github.com/cloudbase/powershell-yaml?tab=readme-ov-file#merge-keys-support

But it does seem to work on the yaml from the above link.

derekwbrown commented 7 months ago

That did indeed work. Thanks!