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

[Bug] .templateignore does not work for variables #478

Open
benedikt-bartscher opened this issue May 13, 2023 · 5 comments
Open

[Bug] .templateignore does not work for variables #478

benedikt-bartscher opened this issue May 13, 2023 · 5 comments

Comments

@benedikt-bartscher
Copy link

Operating system

arch

Kluctl Version

latest

Kubernetes Version

latest

kubectl Version

latest

Bug description

.templateignore seems to not work for variable files included like this:

deployment.yaml

vars:
  - file: vars/global-templateignore.yaml

vars/global-templateignore.yaml

test: {{ slug }}

.templateignore

vars/global-templateignore.yaml

Steps to reproduce

No response

Relevant log output

failed to load deployment config for /****/kluctl: failed to load deployment.yml vars: failed to render vars file vars/global-templateignore.yaml:   File "vars/global-templateignore.yaml", line 1, in top-level template code
    test: {{ slug }}
UndefinedError: 'slug' is undefined
@benedikt-bartscher benedikt-bartscher changed the title [Bug] .templateignore does not work for values [Bug] .templateignore does not work for variables May 13, 2023
@codablock
Copy link
Collaborator

codablock commented May 13, 2023

Hmm, this is because .templateignore is only honoured when whole directories (e.g. kustomize deployments) are being rendered. I'll try to find a way to make it also work with individual files, but can't say when I find time for it.

Until then, you could surround the whole file with {% raw %} and {% endraw %}.

@benedikt-bartscher
Copy link
Author

Surrounding with raw was the first thing i tried. It resulted in this error:

✗ failed to load deployment config for /****/kluctl: failed to load deployment.yml vars: error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{"slug":interface {}(nil)}

However the docs did not mention raw, so i decided to give .templateignore a try

@codablock
Copy link
Collaborator

That is another issue, related to YAML parsing. The parser sees a { after a key, so it assumes an object/dict is following. You have to surround the {{ slug }} with quotes to enforce the parsing to treat it as a string.

@benedikt-bartscher
Copy link
Author

You are right, thanks for pointing me to quotes.
Let's keep this issue open to evaluate/implement .templateignore support for values.

@epcim
Copy link
Contributor

epcim commented Jun 5, 2023

Just cross-linking the idea with shebang, that would either allow to disable rendering, etc. per file etc..
#268 (comment)

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

No branches or pull requests

3 participants