Kubernetes Helm,将两个变量用中间的字符串组合起来 [英] Kubernetes Helm, combine two variables with a string in the middle

查看:31
本文介绍了Kubernetes Helm,将两个变量用中间的字符串组合起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果另一个变量通过将两者与中间的破折号组合来设置,我正在尝试更改变量的值,我不确定执行此操作的语法,我正在考虑以下内容:

I’m trying to change the value of a variable if another variable it set by combining the two with a dash in the middle, I’m not sure of the syntax to do this, I’m thinking of somethings like:

{{- $serviceNamespace := .Values.serviceNamespace -}}
{{- $serviceTag := .Values.serviceTag -}}
{{- if $serviceTag}}
{{- $serviceNamespace := .Values.serviceNamespace  "-" .Values.serviceTag -}}
{{- end}}

这是正确的吗?如果 serviceNamespacehello 并且 serviceTag1.0.0 我会得到 serviceNamespace> 是 hello-1.0.0?

Is this correct? if serviceNamespace was hello and serviceTag was 1.0.0 would I end up with serviceNamespace being hello-1.0.0?

推荐答案

对于连接只需使用 printf:

For concatenation just use printf:

{{-  $serviceNamespace := printf "%s-%s" .Values.serviceNamespace .Values.serviceTag -}}

这篇关于Kubernetes Helm,将两个变量用中间的字符串组合起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆