gpt4 book ai didi

kubernetes-helm - 值文件中的 Helm 连接列表

转载 作者:行者123 更新时间:2023-12-04 07:00:08 25 4
gpt4 key购买 nike

我正在寻找一种解决方案,将我的 values.yaml 中的列表转换为逗号分隔的列表。

值.yaml

app:
logfiletoexclude:
- "/var/log/containers/kube*"
- "/var/log/containers/tiller*"

_helpers.tpl:
{{- define "pathtoexclude" -}}
{{- join "," .Values.app.logfiletoexclude }}
{{- end -}}

配置图:
<source>
@type tail
path /var/log/containers/*.log
exclude_path [{{ template "pathtoexclude" . }}]
...
...
</source>

问题是我的结果中缺少引号
 exclude_path [/var/log/containers/kube*,/var/log/containers/tiller*]

我该如何修复它才能拥有:
  exclude_path ["/var/log/containers/kube*","/var/log/containers/tiller*"] 

我试过:
{{- join "," .Values.app.logfiletoexclude | quote}}

但这给了我:
exclude_path ["/var/log/containers/kube*,/var/log/containers/tiller*"] 

谢谢

最佳答案

双引号应该在 .Values.app.logfiletoexclude 中转义值。
values.yaml是:

app:
logfiletoexclude:
- '"/var/log/containers/kube*"'
- '"/var/log/containers/tiller*"'
_helpers.tpl是:
{{- define "pathtoexclude" -}}
{{- join "," .Values.app.logfiletoexclude }}
{{- end -}}

最后我们有:
exclude_path ["/var/log/containers/kube*","/var/log/containers/tiller*"]

关于kubernetes-helm - 值文件中的 Helm 连接列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49278158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com