我正在尝试制作另一个使用现有辅助功能的辅助功能,但这似乎不起作用。
我在 _helpers.tpl 文件中有以下功能:
{{- define "redis.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 30 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 30 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
现在我正在尝试添加另一个函数来使用上述函数为 redis 构建连接字符串:
{{ - define "redis.connection_string" -}}
{{ - printf "redis://%s:%s/" include "redis.fullname" .Value.port -}} # This line is important. Can we use above function like this?
{{ -end -}}
这是我的 _helpers.tpl 文件的最终内容:
{{- define "redis.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 30 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name .Chart.Name | trunc 30 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{ - define "redis.connection_string" -}}
{{ - printf "redis://%s:%s/" include "redis.fullname" .Value.port -}}
{{ - end -}}
GO 和 Helm 对我来说都是新手,所以即使它可能也无法找出正确的语法。(这是我们在同一个帮助文件中编写 2 个函数的方式吗?)任何人都可以在这里提供帮助。