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

.Value is not cleared inside if condition for index #31

Open
aneeshkp opened this issue Apr 28, 2020 · 1 comment
Open

.Value is not cleared inside if condition for index #31

aneeshkp opened this issue Apr 28, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@aneeshkp
Copy link
Member

After exported .Values is not cleared for index. Index is a sprig function not sure how to handle this.

  • "{{ index .Values "etcd-operator" "cluster" "name" }}-client:2379"

To produce use either use zetcd helm charts or use following template
Template

{{- if .Values.etcd.operatorEnabled }}
            - "-endpoints"
            - "{{ index .Values "etcd-operator" "cluster" "name" }}-client:2379"
{{- else }}
            - "-endpoints"
            - "{{ .Values.etcd.endpoints }}"
{{- end }}

Expected :
{% if etcd.operatorEnabled %}
- "-endpoints"
- "{{ index "etcd-operator" "cluster" "name" }}-client:2379"
{% else %}
- "-endpoints"
- "{{ etcd.endpoints }}"
{% endif %}
Actual Result:
{% if etcd.operatorEnabled %}
- "-endpoints"
- "{{ index .Values "etcd-operator" "cluster" "name" }}-client:2379"
{% else %}
- "-endpoints"
- "{{ etcd.endpoints }}"
{% endif %}

@aneeshkp aneeshkp added the bug Something isn't working label Apr 28, 2020
@aneeshkp
Copy link
Member Author

aneeshkp commented Apr 29, 2020

{{ index .Values "etcd-operator" "cluster" "name" }}
can be writen as {{ etcd-operator.cluster.name }}
But there are cases where the array is returned via a function
{{ index a func() }}

Indexing structures in Templates

If the data passed to the template is a map, slice, or array it can be indexed from the template. We use {{index x number}} where index is the keyword, x is the data and number is a integer for the index value. If we had {{index names 2}} it is equivalent to names[2]. We can add more integers to index deeper into data. {{index names 2 3 4}} is equivalent to names[2][3][4].

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
Development

No branches or pull requests

1 participant