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

"on:" as keyword becomes "true:" #275

Closed
omgnuts opened this issue Jan 24, 2021 · 2 comments
Closed

"on:" as keyword becomes "true:" #275

omgnuts opened this issue Jan 24, 2021 · 2 comments
Labels
bug This issue describes a defect or unexpected behavior

Comments

@omgnuts
Copy link

omgnuts commented Jan 24, 2021

What steps did you take:
Using ytt data values to generate github actions templates, and the "on:" key becomes "true:".

[template.yml]
#@ load("@ytt:data", "data")
---
name: #@ data.values.action_name
on:
  push:
    branches: #@ data.values.action_branch
    paths: #@ data.values.action_paths
...

What happened:
The "on:" key was replaced by "true:"

[ytt-output]
name: Some name to publish
true: <------------------ expected on: instead of true:
  push:
    branches:
    - master
    paths:
    - .github/workflows/some-docker-image.yml

What did you expect:
Expected the "on:" key to remain

[ytt-output]
name: Some name to publish
on: <------------------ expected on: as the correct output
  push:
    branches:
    - master
    paths:
    - .github/workflows/some-docker-image.yml

Anything else you would like to add:
I figure "on:" might be recognized as a boolean flag somewhere. So I tried "off:" as a keyword to test, and it became "false:" as well. Is there a way to tell ytt to preserve certain keywords as is? Eg.

In the meantime, I'm using sed to replace the piped output before generating the output files.

"on":

to become

on:

Environment:

  • ytt version v0.31.0 release
  • Windows 10
@omgnuts omgnuts added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Jan 24, 2021
@danielhelfand danielhelfand added carvel accepted This issue should be considered for future work and that the triage process has been completed and removed carvel triage This issue has not yet been triaged for relevance labels Jan 24, 2021
@danielhelfand
Copy link
Contributor

Thanks for reporting this. I can confirm being able to reproduce this. As you point out, on and off are interpreted by YAML as boolean values leading to the issue above:

ytt -f /tmp/action/workflow.yml -f /tmp/action/values.yml -s

ytt: Error: Unmarshaling YAML template 'workflow.yml': yaml:
  Strict parsing:
    Found 'on' ambigious (could be !!str or !!bool)

It does look like "on": with quotes around it is still interpreted correctly by actions as a temporary workaround.

Can look a bit further on what the appropriate way to get around this scenario is.

@danielhelfand
Copy link
Contributor

Going to close this out as it seems to be a duplicate of #146.

The recommended workaround is to have the on key be a string for now ("on":), but we are going to look into prioritizing this as it appears this has come up quite a few times.

@danielhelfand danielhelfand removed the carvel accepted This issue should be considered for future work and that the triage process has been completed label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a defect or unexpected behavior
Projects
None yet
Development

No branches or pull requests

2 participants