在 helm-template 中,我试图通过键检索地图的值。
我尝试使用indexgo-templates 中的 ,如下所示:
Access a map value using a variable key in a Go template
但是它对我不起作用(见后面的测试)。关于替代解决方案的任何想法?
Chart.yaml:
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: foochart
version: 0.1.0
Run Code Online (Sandbox Code Playgroud)
values.yaml:
label:
- name: foo
value: foo1
- name: bar
value: bar2
Run Code Online (Sandbox Code Playgroud)
templates/test.txt
label: {{ .Values.label }}
Run Code Online (Sandbox Code Playgroud)
适用于helm template .:
---
# Source: foochart/templates/test.txt
label: [map[value:foo1 name:foo] map[name:bar value:bar2]]
Run Code Online (Sandbox Code Playgroud)
但是一旦尝试使用index:
templates/test.txt
label: {{ .Values.label }}
foolabel: {{ index …Run Code Online (Sandbox Code Playgroud)