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

validation misses nested values #23

Open
AFriemann opened this issue Jan 30, 2020 · 3 comments · Fixed by #26
Open

validation misses nested values #23

AFriemann opened this issue Jan 30, 2020 · 3 comments · Fixed by #26
Labels
bug Something isn't working

Comments

@AFriemann
Copy link
Member

AFriemann commented Jan 30, 2020

missing values like {{ foo.bar }} will be missed during validation if foo is defined.

leaving it undefined only recognizes the top level variable as missing

01_configmaps.yaml.j2: ✗
- undefined variable: aws
@AFriemann AFriemann added the bug Something isn't working label Jan 30, 2020
@AFriemann
Copy link
Member Author

AFriemann commented Jan 30, 2020

possible solution via jinja2schema

https://stackoverflow.com/questions/42589514/how-to-get-nested-undeclared-variables-in-python-jinja2

Stack Overflow
I have an xml template and I'm loadind data into it using jinja2 template engine. I'm trying to validate that all the variables in the template are supplied:

from jinja2 import Environment,

AFriemann added a commit that referenced this issue Feb 6, 2020
[#23] fail properly for undefined values instead of templating empty string
@AFriemann AFriemann modified the milestones: 0.2.0, 0.3.0 Feb 6, 2020
@AFriemann
Copy link
Member Author

the merged PR now raises a proper error when nested values are missing but validation still can't detect them properly.

@sl4vr
Copy link
Contributor

sl4vr commented Jun 16, 2020

@AFriemann, the easiest way to check for existence of nested variables is dry-run of rendering. But here we need to choose:

  1. Fail on first undefined nested variable during render, means that if we find undefined, we will interrupt validation.
  2. Fail on first undefined nested variable in every template, means that we still can validate other templates.
  3. Evaluate expression that should raise undefined error to empty string, log error into standard output and proceed.

I've already made a Proof of Concept for third option: #69

@sl4vr sl4vr mentioned this issue Oct 12, 2020
@AFriemann AFriemann removed this from the 0.3.0 milestone Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants