仅获取文件内容,并在此内容上运行`tpl` [kubernetes-helm]

问题描述

我无法找到一种获取文件内容并对该内容运行tpl的方法

Yaml输入输入文件:

spec:
{{- (tpl ($.Files.Glob config.yaml).AsConfig $) | nindent 2 }}

config.yaml的内容

key1: {{ .Values.value1 }}
key2: {{ .Values.value2 }}

values.yaml文件的内容

value1: value1
value2: value2

头盔模板输出:

spec:
  config.yaml: |-
    key1: value2
    key2: value2

我想要的

spec:
  # config.yaml: |- should be removed
  key1: value2
  key2: value2

解决方法

使用.Files.Get代替Glob方法。

spec:
{{ tpl ( .Files.Get "config.yaml" ) . | indent 2 }}

有关更多详细信息,请访问-Accessing Files Inside Templates

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...