![](/img/trans.png)
[英]How to fix `can't evaluate field extraHosts in type interface {}` in _helpers.tpl in helm
[英]Is there function in helm similar to 'tpl' but don't fail if variable is not found
假設我有這樣的文件
it is my text file with name. It contains: {{ var1 }} and {{ var2 }}
假設我有 values.yaml
var2: some_value
如果我嘗試做
{{ (tpl (.Files.Glob "myfile.txt").AsConfig . ) | indent 2 }}
它將失敗,因為var1
未定義
但我想要這樣的結果
it is my text file with name. It contains: {{ var1 }} and some_value
我怎樣才能在掌舵中實現它?
如果執行失敗,則不能 output 模板操作。
您可以做的是在模板中使用default
的 function:
it is my text file with name. It contains:
{{ var1 | default "{{var1}}" }} and {{ var2 | default "{{var2}}" }}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.