我似乎无法找到一个简单有效的解决方案来解决我想象的 Go 模板/Helm 中经常出现的问题。基本上,给定一个像这样的values.yaml:
ingress:
hosts:
- host: busy-a.local
paths:
- backend:
serviceName:busy-a
servicePort: 80
path: /busy/[A-Z0-9]{1}
和 templates/ingress.yaml 像这样:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{.Values.project}}-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
backend:
serviceName: {{ .backend.serviceName }} # this works
servicePort: {{ .backend.servicePort }} # but can we shorthand backend?
{{- end }}
{{- end }}
backend但是,在 中“解压”地图不是更容易.paths range吗backend: {{.backend}}?然而,它似乎并不是那样工作的。
...
paths:
- path: /busy/[A-Z0-9]{3}
backend: map[serviceName:busy-a servicePort:80]
在 Go 模板或 Sprig 扩展中解压或分配整个对象的首选方法是什么?
小怪兽爱吃肉
相关分类