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

"isset" does not work inside ranges #23

Open
totemcaf opened this issue May 20, 2019 · 0 comments
Open

"isset" does not work inside ranges #23

totemcaf opened this issue May 20, 2019 · 0 comments

Comments

@totemcaf
Copy link

totemcaf commented May 20, 2019

The following template iterates over a range "entries" and inside each iteration checks if a value is set in the current iteration value:

# kubetpl:syntax:go-template

a-start: Here the YAML starts
{{- if isset "key" }}
msg: "Found value for key: {{ .key }}"
{{- else }}
error: "Key value is missing"
{{- end}}

an-output-entry:
{{ range $ig := .entries }}
  - the-name: {{ .name }}
    output: {{ .value }}
    {{- if isset "print" }}
    the-value-to-print: {{ .print }}
    {{- end }}
{{ end }}
z-end: The last entry

Sample values:

key: some value

entries:
  - name: one
    value: first value
    print: value to print
  - name: two
    value: the second
    print: another value
  - name: three
    value: the third

The actual result:

---
a-start: Here the YAML starts
an-output-entry:
- output: first value
  the-name: one
- output: the second
  the-name: two
- output: the third
  the-name: three
msg: 'Found value for key: some value'

The expected result:

---
a-start: Here the YAML starts
an-output-entry:
- output: first value
  the-name: one
  the-value-to-print: value to print
- output: the second
  the-name: two
  the-value-to-print: another value
- output: the third
  the-name: three
msg: 'Found value for key: some value'

The check {{- if isset "print" }} fails always inside the retries range.

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

1 participant