Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml escaping seen as string and not boolean #913

Closed
smerle33 opened this issue May 14, 2024 · 3 comments
Closed

yaml escaping seen as string and not boolean #913

smerle33 opened this issue May 14, 2024 · 3 comments
Labels

Comments

@smerle33
Copy link

smerle33 commented May 14, 2024

Describe the bug
if I escape the skip part I got and unmarshal error

visualstudio:
    exec: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe -nologo -version
    exit-status: 0
    stdout:
      - /16\.\d+\.\d+\.\d+/
    skip: '{{ not (eq .Env.AGENT_OS_VERSION "2019") }}'
export GOSS_USE_ALPHA=1; export AGENT_OS_VERSION=2022; goss -g ./goss/goss-windows.yaml render
2024/05/14 14:30:33 yaml: unmarshal errors:
  line 62: cannot unmarshal !!str `true` into bool

but if I don't escape then the yaml seems to be wrong as told by https://github.com/goccy/go-yaml/tree/master
(used within updatecli):

visualstudio:
    exec: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe -nologo -version
    exit-status: 0
    stdout:
      - /16\.\d+\.\d+\.\d+/
    skip: {{ not (eq .Env.AGENT_OS_VERSION "2019") }}
ERROR: something went wrong in target "updateJDK21VersionInGoss" : "updating yaml file: parsing yaml file: [62:12] unexpected mapping key\n      59 |     exit-status: 0\n      60 |     stdout:\n      61 |       - /16\\.\\d+\\.\\d+\\.\\d+/\n    > 62 |     skip: {{ not (eq .Env.AGENT_OS_VERSION \"2019\") }}\n                      ^\n      63 | file:\n      64 |   C:\\Program Files\\Chromium\\Application\\:\n      65 |     contains: []"

How To Reproduce
everything is public here : https://github.com/jenkins-infra/packer-images
from the goss file: https://github.com/jenkins-infra/packer-images/blob/main/goss/goss-windows.yaml
to one of the updatecli manifest that break if the skip line is not escape: https://github.com/jenkins-infra/packer-images/blob/main/updatecli/updatecli.d/jdk21.yml

export GOSS_USE_ALPHA=1; export AGENT_OS_VERSION=2022; goss -g ./goss/goss-windows.yaml render

updatecli diff --values ./updatecli/values.yaml --config ./updatecli/updatecli.d/jdk21.yml

Expected Behavior
that this version:

visualstudio:
    exec: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe -nologo -version
    exit-status: 0
    stdout:
      - /16\.\d+\.\d+\.\d+/
    skip: '{{ not (eq .Env.AGENT_OS_VERSION "2019") }}'

or

visualstudio:
    exec: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe -nologo -version
    exit-status: 0
    stdout:
      - /16\.\d+\.\d+\.\d+/
    skip: |
        {{ not (eq .Env.AGENT_OS_VERSION "2019") }}

manage to convert true or false string to boolean

Actual Behavior
error
line 62: cannot unmarshal !!str true into bool

Environment:

  • Version of goss goss version v0.4.2
@smerle33
Copy link
Author

in fact the online version should be seen as correct yaml, changing the engine on the updatecli solved the issue.

@aelsabbahy
Copy link
Member

Sounds like updatecli had/has the bug?

@pilere
Copy link

pilere commented May 20, 2024

Sounds like updatecli had/has the bug?

not really, but depending on the yaml engine used, it's seen as wrong yaml ... the smart thing about updatecli is that you can choose your yaml engine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants