Helm 包含了很多可以在模板中利用的模板函数。以下列出了具体分类:
Logic and Flow Control Functions
Helm 包括了需要逻辑和流控制函数,包括 and, coalesce, default, empty, eq, fail, ge, gt, le, lt, ne, not, and or。
and
返回两个参数的and布尔值。
and .Arg1 .Arg2
or
返回两个参数的or布尔值。会返回第一个非空参数或最后一个参数。
or .Arg1 .Arg2
not
返回参数的布尔求反。
not .Arg
eq
返回参数的布尔等式(比如, Arg1 == Arg2)。
eq .Arg1 .Arg2
ne
返回参数的布尔非等式(比如 Arg1 != Arg2)。
ne .Arg1 .Arg2
lt
如果第一参数小于第二参数,返回布尔真。否则返回假(比如, Arg1 < Arg2)。
lt .Arg1 .Arg2
le
如果第一参数小于等于第二参数,返回布尔真,否则返回假(比如, Arg1 <= Arg2)。
le .Arg1 .Arg2
gt
如果第一参数大于第二参数,返回布尔真,否则返回假(比如, Arg1 > Arg2)。
gt .Arg1 .Arg2
ge
如果第一参数大于等于第二参数,返回布尔真,否则返回假。(比如, Arg1 >= Arg2)。
ge .Arg1 .Arg2
default
defaultdefault "foo" .Bar
.Barfoo"空"定义取决于以下类型:
[]{}falsenil对于结构体,没有空的定义,所以结构体从来不会返回默认值。
empty
emptytruefalsedefaultempty .Foo
if not empty .Fooif .Foofail
stringerrorfail "Please accept the end user license agreement"
coalesce
coalescecoalesce 0 1 2
1此函数用于扫描多个变量或值:
coalesce .name .parent.name "Matt"
.name.parent.name.name.parent.nameMattternary
ternarytrue test value
ternary "foo" "bar" true
或者
true | ternary "foo" "bar"
"foo"false test value
ternary "foo" "bar" false
或者
false | ternary "foo" "bar"
"bar"String Functions
Helm 包含了一下字符串函数: abbrev, abbrevboth, camelcase, cat, contains, hasPrefix, hasSuffix, indent, initials, kebabcase, lower, nindent, nospace, plural, print, printf, println, quote, randAlpha, randAlphaNum, randAscii, randNumeric, repeat, replace, shuffle, snakecase, squote, substr, swapcase, title, trim, trimAll, trimPrefix, trimSuffix, trunc, untitle, upper, wrap, 和 wrapWith
返回各部分组合的字符串。
print "Matt has " .Dogs " dogs"
如果可能,非字符串类型会被转换成字符串。
注意,当相邻两个参数不是字符串时会在它们之间添加一个空格。
println
和 print效果一样,但会在末尾新添加一行。
printf
返回参数按顺序传递的格式化字符串。
printf "%s has %d dogs." .Name .NumberDogs
占位符取决于传入的参数类型。这包括:
一般用途:
%v%+v%%布尔值:
%t整型:
%b%c%d%o%O%q%x%X%U浮点数和复杂成分
%b%e%E%f%F%g%G%x%X字符串和字节切片:
%s%q%x%X切片:
%ptrim
trimtrim " hello "
hellotrimAll
从字符串中移除给定的字符:
trimAll "$" "$5.00"
5.00trimPrefix
从字符串中移除前缀:
trimPrefix "-" "-hello"
hellotrimSuffix
从字符串中移除后缀:
trimSuffix "-" "hello-"
hellolower
将整个字符串转换成小写:
lower "HELLO"
helloupper
将整个字符串转换成大写:
upper "hello"
HELLOtitle
首字母转换成大写:
title "hello world"
Hello Worlduntitle
untitle "Hello World"hello worldrepeat
重复字符串多次:
repeat 3 "hello"
hellohellohellosubstr
获取字符串的子串,有三个参数:
- start (int)
- end (int)
- string (string)
substr 0 5 "hello world"
hellonospace
去掉字符串中的所有空格:
nospace "hello w o r l d"
helloworldtrunc
截断字符串。
trunc 5 "hello world"
hellotrunc -5 "hello world"
worldabbrev
...参数:
- 最大长度
- 字符串
abbrev 5 "hello world"
he...abbrevboth
两边都省略
abbrevboth 5 10 "1234 5678 9123"
...5678...It takes:
- 左侧偏移值
- 最大长度
- 字符串
initials
截取给定字符串每个单词的首字母,并组合在一起。
initials "First Try"
FTrandAlphaNum, randAlpha, randNumeric, and randAscii
crypto/randrandAlphaNum0-9a-zA-ZrandAlphaa-zA-ZrandNumeric0-9randAscii每个函数都需要一个参数:字符串的整型长度
randNumeric 3
上述会生成三个数字的字符串。
wrap
以给定列数给文字换行。
wrap 80 $someText
$someTextwrapWith
wrapWithwrapwrap\nwrapWith 5 "\t" "Hello World"
hello worldcontains
测试字符串是否包含在另一个字符串中:
contains "cat" "catch"
truecatchcathasPrefix and hasSuffix
hasPrefixhasSuffixhasPrefix "cat" "catch"
truecatchcatquote and squote
quotesquotecat
catcat "hello" "beautiful" "world"
hello beautiful worldindent
indentindent 4 $lots_of_text
上述结果会将每行缩进4个空格。
nindent
nindentnindent 4 $lots_of_text
上述结果会在字符串所在行缩进4个字符,并且在开头新添加一行。
replace
执行简单的字符串替换。
需要三个参数
- 待替换字符串
- 要替换字符串
- 源字符串
"I Am Henry VIII" | replace " " "-"
I-Am-Henry-VIIIplural
字符串复数化。
len $fish | plural "one anchovy" "many anchovies"
one anchovymany anchovies参数包括:
- 单数字符串
- 复数字符串
- 整型长度
0zero anchoviessnakecase
将驼峰写法转换成蛇形写法。
snakecase "FirstName"
first_namecamelcase
将字符串从蛇形写法转换成驼峰写法。
camelcase "http_server"
HttpServerkebabcase
将驼峰写法转换成烤串写法。
kebabcase "FirstName"
first-nameswapcase
基于单词的算法切换字符串的大小写。
转换算法:
- 大写字符变成小写字母
- 首字母变成小写字母
- 空格后或开头的小写字母转换成大写字母
- 其他小写字母转换成大写字母
- 通过unicode.IsSpace(char)定义空格
swapcase "This Is A.Test"
tHIS iS a.tESTshuffle
对字符串进行洗牌。
shuffle "hello"
hellooelhlType Conversion Functions
Helm提供了以下类型转换函数:
atoifloat64float64intintint64int64toDecimalint64toStringtoStringstoJsonmustToJsontoPrettyJsonmustToPrettyJsontoRawJsonmustToRawJsonfromYamlfromJsontoYamlatoiint64toStrings
给定一个类列表集合,输出字符串切片。
list 1 2 3 | toStrings
1"1"2"2"toDecimal
给定一个unix八进制权限,转换成十进制。
"0777" | toDecimal
0777511toJson, mustToJson
toJsonmustToJsontoJson .Item
.ItemtoPrettyJson, mustToPrettyJson
toPrettyJsontoPrettyJson .Item
.ItemtoRawJson, mustToRawJson
toRawJsontoRawJson .Item
.ItemfromYaml
fromYaml文件位置: yamls/person.yamlname: Bob
age: 25
hobbies:
- hiking
- fishing
- cooking
{{- $person := .Files.Get "yamls/person.yaml" | fromYaml }}
greeting: |
Hi, my name is {{ $person.name }} and I am {{ $person.age }} years old.
My hobbies are {{ range $person.hobbies }}{{ . }} {{ end }}.
fromJson
fromJson文件位置: jsons/person.json{
"name": "Bob",
"age": 25,
"hobbies": [
"hiking",
"fishing",
"cooking"
]
}
{{- $person := .Files.Get "jsons/person.json" | fromJson }}
greeting: |
Hi, my name is {{ $person.name }} and I am {{ $person.age }} years old.
My hobbies are {{ range $person.hobbies }}{{ . }} {{ end }}.
Regular Expressions
Helm 包含以下正则表达式函数 regexFind(mustRegexFind), regexFindAll(mustRegexFindAll), regexMatch (mustRegexMatch), regexReplaceAll (mustRegexReplaceAll), regexReplaceAllLiteral(mustRegexReplaceAllLiteral), regexSplit (mustRegexSplit)。
regexMatch, mustRegexMatch
如果输入字符串包含可匹配正则表达式任意字符串,则返回true。
regexMatch "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$" "test@acme.com"
trueregexMatchmustRegexMatchregexFindAll, mustRegexFindAll
返回输入字符串匹配正则表达式的所有切片。最后一个参数表示要返回的子字符串的数量,-1表示返回所有。
regexFindAll "[2,4,6,8]" "123456789" -1
[2 4 6 8]regexFindAllmustRegexFindAllregexFind, mustRegexFind
返回输入字符串的第一个 (最左边的) 正则匹配。
regexFind "[a-zA-Z][1-9]" "abcd1234"
d1regexFindmustRegexFindregexReplaceAll, mustRegexReplaceAll
返回输入字符串的拷贝,用替换字符串替换Regexp的匹配项。在替换字符串里面, $ 标志被解释为扩展,因此对于实例来说 $1 表示第一个子匹配的文本
regexReplaceAll "a(x*)b" "-ab-axxb-" "${1}W"
-W-xxW-regexReplaceAllmustRegexReplaceAllregexReplaceAllLiteral, mustRegexReplaceAllLiteral
返回输入字符串的拷贝,用替换字符串替换Regexp的匹配项。匹配字符串直接替换而不是扩展。
regexReplaceAllLiteral "a(x*)b" "-ab-axxb-" "${1}"
-${1}-${1}-regexReplaceAllLiteralmustRegexReplaceAllLiteralregexSplit, mustRegexSplit
n-1regexSplit "z+" "pizza" -1
[pi a]regexSplitmustRegexSplitCryptographic and Security Functions
Helm提供了一些高级的加密函数。包括了 adler32sum, buildCustomCert, decryptAES, derivePassword, encryptAES, genCA, genPrivateKey, genSelfSignedCert, genSignedCert, htpasswd, sha1sum, 以及 sha256sum。
sha1sum
sha1sumsha1sum "Hello world!"
sha256sum
sha256sumsha256sum "Hello world!"
上述语句会以“ASCII包装”格式计算SHA 256 校验和,并安全打印出来。
adler32sum
adler32sumadler32sum "Hello world!"
htpasswd
htpasswdusernamepasswordbcrypthtpasswd "myUser" "myPassword"
注意,将密码直接存储在模板中并不安全。
derivePassword
derivePasswordderivePassword 1 "long" "password" "user" "example.com"
注意,将这部分直接存储在模板中并不安全。
genPrivateKey
genPrivateKey第一个参数会采用以下某个值:
ecdsadsarsabuildCustomCert
buildCustomCert会采用以下字符串参数:
- base64 编码PEM格式证书
- base64 编码PEM格式私钥
返回包含以下属性的整数对象:
CertKey示例:
$ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-key"
genSignedCertgenCA
genCA会采用以下参数:
- 主体通用名 (cn)
- 证书有效期(天)
会返回一个包含以下属性的对象:
CertKey示例:
$ca := genCA "foo-ca" 365
genSignedCertgenSelfSignedCert
genSelfSignedCert会采用下列参数:
- 主体通用名 (cn)
- 可选IP列表;可以为空
- 可选备用DNS名称列表;可以为空
- 证书有效期(天)
会返回一个包含以下属性的对象:
CertKey示例:
$cert := genSelfSignedCert "foo.com" (list "10.0.0.1" "10.0.0.2") (list "bar.com" "bat.com") 365
genSignedCert
genSignedCert会采用以下参数:
genCA示例:
$ca := genCA "foo-ca" 365
$cert := genSignedCert "foo.com" (list "10.0.0.1" "10.0.0.2") (list "bar.com" "bat.com") 365 $ca
encryptAES
encryptAESencryptAES "secretkey" "plaintext"
decryptAES
decryptAES"30tEfhuJSVRhpG97XCuWgz2okj7L8vQ1s6V9zVUPeDQ=" | decryptAES "secretkey"
Date Functions
Helm 包含以下可以在模板中使用的函数: ago, date, dateInZone, dateModify(mustDateModify), duration, durationRound, htmlDate, htmlDateInZone, now, toDate(mustToDate), and unixEpoch。
now
当前日期/时间。和其他日期函数一起使用。
ago
agoago .CreatedAt
time.Duration2h34m7s
date
date日期格式化为YEAR-MONTH-DAY:
now | date "2006-01-02"
日期格式化在Go中有 一些不同。
简言之,以此为基准日期:
Mon Jan 2 15:04:05 MST 2006
2006-01-02dateInZone
datedateInZone "2006-01-02" (now) "UTC"
duration
time.Duration这会返回 1m35s。
duration 95
durationRound
time.Timetime.Duration这会返回2h
durationRound "2h10m5s"
这会返回3mo
durationRound "2400h10m5s"
unixEpoch
time.Timenow | unixEpoch
dateModify, mustDateModify
dateModify从当前时间减去一个小时三十分钟:
now | date_modify "-1.5h"
dateModifymustDateModifyhtmlDate
htmlDatenow | htmlDate
htmlDateInZone
和htmlDate一样,但多了个时区。
htmlDateInZone (now) "UTC"
toDate, mustToDate
toDatemustToDate这在你将日期字符串转换成其他格式时很有用(使用pipe)。下面的例子会将"2017-12-31" 转换成 "31/12/2017"。
toDate "2006-01-02" "2017-12-31" | date "02/01/2006"
Dictionaries and Dict Functions
dictdictdictlistlistdictsetunsetHelm 提供了以下函数支持使用字典: deepCopy(mustDeepCopy), dict, dig, get, hasKey, keys, merge (mustMerge), mergeOverwrite (mustMergeOverwrite), omit, pick, pluck, set, unset,和 values。
dict
dict下面是创建三个键值对的字典:
$myDict := dict "name1" "value1" "name2" "value2" "name3" "value 3"
get
给定一个映射和一个键,从映射中获取值。
get $myDict "name1"
"value1"""set
set$_ := set $myDict "name4" "value4"
set$_unset
给定一个映射和key,从映射中删除这个key。
$_ := unset $myDict "name4"
set注意,如果key没有找到,这个操作会简单返回,不会生成错误。
hasKey
hasKeytruehasKey $myDict "name1"
falsepluck
pluckpluck "name1" $myDict $myOtherDict
list[value1 otherValue1]pluck如果key是 存在的, 但是值是空值,会插入一个值。
pluck... | firstdig
digdig "user" "role" "humanName" "guest" $dict
给一个结构化的字典如下:
{
user: {
role: {
humanName: "curator"
}
}
}
"curator"user"guest"andand a.maybeNil a.maybeNil.iNeedThisa.maybeNil.iNeedThismaybeNiladigmerge a b c | dig "one" "two" "three" "<missing>"
merge, mustMerge
将两个或多个字典合并为一个, 目标字典优先:
给出:
dst:
default: default
overwrite: me
key: true
src:
overwrite: overwritten
key: false
会得到结果:
newdict:
default: default
overwrite: me
key: true
$newdict := merge $dest $source1 $source2
deepCopydeepCopy $source | merge $dest
mustMergemergeOverwrite, mustMergeOverwrite
合并两个或多个字典,优先按照 从右到左,在目标字典中有效地覆盖值:
给定的:
dst:
default: default
overwrite: me
key: true
src:
overwrite: overwritten
key: false
会生成:
newdict:
default: default
overwrite: overwritten
key: false
$newdict := mergeOverwrite $dest $source1 $source2
deepCopydeepCopy $source | mergeOverwrite $dest
mustMergeOverwritekeys
keysdictlistsortAlphakeys $myDict | sortAlpha
uniqsortAlphakeys $myDict $myOtherDict | uniq | sortAlpha
pick
pickdict$new := pick $myDict "name1" "name2"
{name1: value1, name2: value2}omit
omitpickdict$new := omit $myDict "name1" "name3"
{name2: value2}values
valueskeyslist$vals := values $myDict
list["value1", "value2", "value 3"]valuessortAlphadeepCopy, mustDeepCopy
deepCopymustDeepCopydeepCopymustDeepCopydict "a" 1 "b" 2 | deepCopy
字典的内部说明
dictmap[string]interface{}map[string]interface{}dictEncoding functions
Helm有以下编码和解码函数:
b64encb64decb32encb32decLists and List Functions
list创建一个整型列表:
$myList := list 1 2 3 4 5
[1 2 3 4 5]Helm 提供了以下列表函数: append(mustAppend), compact (mustCompact), concat, first(mustFirst), has (mustHas), initial (mustInitial), last (mustLast), prepend (mustPrepend), rest (mustRest), reverse (mustReverse), seq, index, slice (mustSlice), uniq (mustUniq), until, untilStep, 和 without (mustWithout)。
first, mustFirst
firstfirst $myList1firstmustFirstrest, mustRest
restrest $myList[2 3 4 5]restmustRestlast, mustLast
lastlast $myList5firstinitial, mustInitial
lastinitial $myList[1 2 3 4]initialmustInitialappend, mustAppend
在已有列表中追加一项,创建一个新的列表。
$new = append $myList 6
$new[1 2 3 4 5 6]$myListappendmustAppendprepend, mustPrepend
将元素添加到列表的前面,生成一个新的列表。
prepend $myList 0
[0 1 2 3 4 5]$myListprependmustPrependconcat
将任意数量的列表串联成一个。
concat $myList ( list 6 7 ) ( list 8 )
[1 2 3 4 5 6 7 8]$myListreverse, mustReverse
反转给定的列表生成一个新列表。
reverse $myList
[5 4 3 2 1]reversemustReverseuniq, mustUniq
生成一个移除重复项的列表。
list 1 1 1 2 | uniq
[1 2]uniqmustUniqwithout, mustWithout
withoutwithout $myList 3
[1 2 4 5]一个过滤器可以过滤多个元素:
without $myList 1 3 5
[2 4]withoutmustWithouthas, mustHas
验证列表是否有特定元素。
has 4 $myList
truehas "hello" $myListhasmustHascompact, mustCompact
接收一个列表并删除空值项。
$list := list 1 "a" "foo" ""
$copy := compact $list
compactcompactmustCompactindex
index list [n]index list [n] [m] ...index $myList 01myList[0]index $myList 0 1myList[0][1]slice, mustSlice
slice list [n] [m]list[n:m]slice $myList[1 2 3 4 5]myList[:]slice $myList 3[4 5]myList[3:]slice $myList 1 3[2 3]myList[1:3]slice $myList 0 3[1 2 3]myList[:3]slicemustSliceuntil
untiluntil 5
[0, 1, 2, 3, 4]range $i, $e := until 5untilStep
untiluntilStepuntilStep 3 6 2
[3 5]rangeseq
seqendstartendstartendstepseq 5 => 1 2 3 4 5
seq -3 => 1 0 -1 -2 -3
seq 0 2 => 0 1 2
seq 2 -2 => 2 1 0 -1 -2
seq 0 2 10 => 0 2 4 6 8 10
seq 0 -2 -5 => 0 -2 -4
Math Functions
int64有以下math函数可用: add, add1, ceil, div, floor, len, max, min, mod, mul, round, and [sub](#sub)。
add
addadd 1 2 3
add1
add1sub
subdiv
divmod
modmul
mulmul 1 2 3
max
返回一组整数中最大的整数。
3max 1 2 3
min
返回一组数中最小的数。
min 1 2 31len
返回参数的长度。
len .Arg
Float Math Functions
float64addf
addf5.5addf 1.5 2 2
add1f
add1fsubf
subf7.5 - 2 - 32.5subf 7.5 2 3
divf
divf10 / 2 / 41.25divf 10 2 4
mulf
mulf6mulf 1.5 2 2
maxf
返回最大浮点数
3maxf 1 2.5 3
minf
返回最小浮点数
1.5minf 1.5 2 3
floor
返回小于等于输入值的最大浮点整数。
floor 123.9999123.0ceil
返回大于等于输入值的最小浮点整数。
ceil 123.001124.0round
返回一个四舍五入到给定小数位的数。
round 123.555555 3123.556Network Functions
getHostByNamegetHostByNamegetHostByName "www.google.com"www.google.comFile Path Functions
Helm模板函数没有访问文件系统的权限,提供了遵循文件路径规范的函数。包括 base, clean, dir, ext, 和 isAbs 。
base
返回最后一个元素路径。
base "foo/bar/baz"
返回 "baz"。
dir
dir "foo/bar/baz"foo/barclean
清除路径
clean "foo/bar/../baz"
..foo/bazext
返回文件扩展。
ext "foo.bar"
.barisAbs
isAbsReflection Functions
Helm 提供了基本的反射工具。这有助于高级模板开发者理解特定值的基本Go类型信息。Helm是由Go编写的且是强类型的。 类型系统应用于模板中。
stringsliceint64boolGo 有一个开放的 类型 系统,允许开发者创建自己的类型。
Helm 通过 kind functions 和 type functions 提供了一组函数。 deepEqual 也可以用来比较值。
Kind Functions
kindOfkindOf "hello"
stringifKindiskindIs "int" 123
trueType Functions
类型处理起来稍微有点复杂,所以有三个不同的函数:
typeOftypeOf $footypeIskindIstypeIs "*io.Buffer" $myValtypeIsLiketypeIs注意: 这些都不能测试是否实现了给定的接口,因为在这之前需要提前编译接口。
deepEqual
deepEqualeqdeepEqual (list 1 2 3) (list 1 2 3)
trueSemantic Version Functions
有些版本结构易于分析和比较。Helm提供了适用于 SemVer 2 版本的函数。包括 semver和 semverCompare。下面你也能看到使用范围和比较的细节。
semver
semver$version := semver "1.2.3-alpha.1+123"
如果解析失败,会由一个错误引起模板执行中断。
$versionVersion$version.Major1$version.Minor2$version.Patch3$version.Prereleasealpha.1$version.Metadata123$version.OriginalCompareVersionversionsemver "1.4.3" | (semver "1.2.3").Compare
-1返回值可以是:
-1Compare1Compare0MetadatasemverCompare
semverComparesemverCompare "1.2.3" "1.2.3"semverCompare "~1.2.0" "1.2.3"SemVer函数使用 semver规划库,由Sprig作者创建。
基本比较
">= 1.2 < 3.0.0 || >= 4.2.3"基本比较符有:
=!=><>=<=使用预发布版本
1.2.31.2.3-beta.11.2.3-beta.1 < 1.2.3根据语义版本指定的预发布版本可能不与对应的发行版本兼容。
预发布版本表示版本不稳定且可能不满足其相关正常版本所表示的预期兼容性要求。
>=1.2.3>=1.2.3-00..0>=1.2.3-BETA1.2.3-alpha连字符范围比较
有多个方法处理范围,首先是连字符范围。像这样:
1.2 - 1.4.5>= 1.2 <= 1.4.52.3.4 - 4.5>= 2.3.4 <= 4.5比较中通配符
xX*=1.2.x>= 1.2.0, < 1.3.0>= 1.2.x>= 1.2.0<= 2.x< 3*>= 0.0.0波浪符号范围比较 (补丁版本)
~~1.2.3>= 1.2.3, < 1.3.0~1>= 1, < 2~2.3>= 2.3, < 2.4~1.2.x>= 1.2.0, < 1.3.0~1.x>= 1, < 2插入符号比较 (主要版本)
^^1.2.3>= 1.2.3, < 2.0.0^1.2.x>= 1.2.0, < 2.0.0^2.3>= 2.3, < 3^2.x>= 2.0.0, < 3^0.2.3>=0.2.3 <0.3.0^0.2>=0.2.0 <0.3.0^0.0.3>=0.0.3 <0.0.4^0.0>=0.0.0 <0.1.0^0>=0.0.0 <1.0.0URL Functions
Helm 包含 urlParse, urlJoin, 和 urlquery 函数可以用做处理URL。
urlParse
解析URL的字符串并生成包含URL部分的字典。
urlParse "http://admin:secret@server.com:8080/api?list=false#anchor"
上述结果为: 包含URL对象的字典:
scheme: 'http'
host: 'server.com:8080'
path: '/api'
query: 'list=false'
opaque: nil
fragment: 'anchor'
userinfo: 'admin:secret'
这是使用Go标准库中的URL包实现的。更多信息,请查看 https://golang.org/pkg/net/url/#URL。
urlJoin
urlParseurlJoin (dict "fragment" "fragment" "host" "host:80" "path" "/path" "query" "query" "scheme" "http")
上述结果会生成以下字符串:
http://host:80/path?query#fragment
urlquery
返回作为参数传入的值的转义版本,这样就可以嵌入到URL的查询部分。
$var := urlquery "string for query"
UUID Functions
Helm 可以生成UUID v4 通用唯一ID。
uuidv4
上述结果为: 一个新的v4类型的UUID(随机生成)。
Kubernetes and Chart Functions
Helm 包含了用于 Kubernetes的函数,包括 .Capabilities.APIVersions.Has, Files, 和 lookup。
lookup
lookuphelm template.Capabilities.APIVersions.Has
返回API版本或资源是否在集群中可用。
.Capabilities.APIVersions.Has "apps/v1"
.Capabilities.APIVersions.Has "apps/v1/Deployment"
更多信息可查看 内置对象文档。
File Functions
有几个函数能使您能够访问chart中的非特殊文件。比如访问应用配置文件。请查看 模板中访问文件。
注意,这里很多函数的文档是来自 Sprig。Sprig是一个适用于Go应用的函数模板库。