首页 新闻 会员 周边 捐助

helm 模板中字符串拆分问题

0
悬赏园豆:30 [已解决问题] 解决于 2022-11-02 22:46

如果 .Release.Name 是 payment-wechat-api,如何拆分为 payment-wechatapi

dudu的主页 dudu | 高人七级 | 园豆:30755
提问于:2022-11-02 22:16
< >
分享
最佳答案
0
  • 通过 (splitList "-" .Release.Name) | initial | join "-" 得到 payment-wechat
  • 通过 (splitList "-" .Release.Name) | last 得到 api

模板代码如下:

subPath: {{ (splitList "-" .Release.Name) | initial | join "-" }}/{{ (splitList "-" .Release.Name) | last }}/

initial 的作用:

This compliments last by returning all but the last element.

详见 http://masterminds.github.io/sprig/lists.html

dudu | 高人七级 |园豆:30755 | 2022-11-02 22:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册