You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-11Lines changed: 15 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -384,7 +384,6 @@ For example, this is a JSON version of an emitted RuntimeContainer struct:
384
384
-[Functions from Go](https://pkg.go.dev/text/template#hdr-Functions)
385
385
-[Functions from Sprig v3](https://masterminds.github.io/sprig/), except for those that have the same name as one of the following functions.
386
386
-_`closest $array $value`_: Returns the longest matching substring in `$array` that matches `$value`
387
-
-_`coalesce ...`_: Returns the first non-nil argument.
388
387
-_`comment $delimiter $string`_: Returns `$string` with each line prefixed by `$delimiter` (helpful for debugging combined with Sprig `toPrettyJson`: `{{ toPrettyJson $ | comment "#" }}`).
389
388
-_`contains $map $key`_: Returns `true` if `$map` contains `$key`. Takes maps from `string` to any type.
390
389
-_`dir $path`_: Returns an array of filenames in the specified `$path`.
@@ -398,23 +397,13 @@ For example, this is a JSON version of an emitted RuntimeContainer struct:
398
397
-_`groupByLabelWithDefault $containers $label $defaultValue`_: Returns the same as `groupBy` but grouping by the given label's value. Containers that do not have the `$label` set are included in the map under the `$defaultValue` key.
399
398
-_`include $file`_: Returns content of `$file`, and empty string if file reading error.
400
399
-_`intersect $slice1 $slice2`_: Returns the strings that exist in both string slices.
401
-
-_`json $value`_: Returns the JSON representation of `$value` as a `string`.
402
400
-_`fromYaml $string` / `mustFromYaml $string`_: Similar to [Sprig's `fromJson` / `mustFromJson`](https://github.com/Masterminds/sprig/blob/master/docs/defaults.md#fromjson-mustfromjson), but for YAML.
403
401
-_`toYaml $dict` / `mustToYaml $dict`_: Similar to [Sprig's `toJson` / `mustToJson`](https://github.com/Masterminds/sprig/blob/master/docs/defaults.md#tojson-musttojson), but for YAML.
404
402
-_`keys $map`_: Returns the keys from `$map`. If `$map` is `nil`, a `nil` is returned. If `$map` is not a `map`, an error will be thrown.
405
-
-_`parseBool $string`_: parseBool returns the boolean value represented by the string. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error. Alias for [`strconv.ParseBool`](http://golang.org/pkg/strconv/#ParseBool)
406
-
-_`replace $string $old $new $count`_: Replaces up to `$count` occurences of `$old` with `$new` in `$string`. Alias for [`strings.Replace`](http://golang.org/pkg/strings/#Replace)
407
-
-_`sha1 $string`_: Returns the hexadecimal representation of the SHA1 hash of `$string`.
408
-
-_`split $string $sep`_: Splits `$string` into a slice of substrings delimited by `$sep`. Alias for [`strings.Split`](http://golang.org/pkg/strings/#Split)
409
-
-_`splitN $string $sep $count`_: Splits `$string` into a slice of substrings delimited by `$sep`, with number of substrings returned determined by `$count`. Alias for [`strings.SplitN`](https://golang.org/pkg/strings/#SplitN)
410
403
-_`sortStringsAsc $strings`_: Returns a slice of strings `$strings` sorted in ascending order.
411
404
-_`sortStringsDesc $strings`_: Returns a slice of strings `$strings` sorted in descending (reverse) order.
412
405
-_`sortObjectsByKeysAsc $objects $fieldPath`_: Returns the array `$objects`, sorted in ascending order based on the values of a field path expression `$fieldPath`.
413
406
-_`sortObjectsByKeysDesc $objects $fieldPath`_: Returns the array `$objects`, sorted in descending (reverse) order based on the values of a field path expression `$fieldPath`.
414
-
-_`trimPrefix $prefix $string`_: If `$prefix` is a prefix of `$string`, return `$string` with `$prefix` trimmed from the beginning. Otherwise, return `$string` unchanged.
415
-
-_`trimSuffix $suffix $string`_: If `$suffix` is a suffix of `$string`, return `$string` with `$suffix` trimmed from the end. Otherwise, return `$string` unchanged.
416
-
-_`toLower $string`_: Replace capital letters in `$string` to lowercase.
417
-
-_`toUpper $string`_: Replace lowercase letters in `$string` to uppercase.
418
407
-_`when $condition $trueValue $falseValue`_: Returns the `$trueValue` when the `$condition` is `true` and the `$falseValue` otherwise
419
408
-_`where $items $fieldPath $value`_: Filters an array or slice based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value. Returns an array of items having that value.
420
409
-_`whereNot $items $fieldPath $value`_: Filters an array or slice based on the values of a field path expression `$fieldPath`. A field path expression is a dot-delimited list of map keys or struct member names specifying the path from container to a nested value. Returns an array of items **not** having that value.
@@ -426,6 +415,21 @@ For example, this is a JSON version of an emitted RuntimeContainer struct:
426
415
-_`whereLabelDoesNotExist $containers $label`_: Filters a slice of containers based on the non-existence of the label `$label`.
427
416
-_`whereLabelValueMatches $containers $label $pattern`_: Filters a slice of containers based on the existence of the label `$label` with values matching the regular expression `$pattern`.
428
417
418
+
Some functions are aliases for Go's [`strings`](https://pkg.go.dev/strings) package functions:
419
+
420
+
-_`parseBool $string`_: Alias for [`strconv.ParseBool`](http://golang.org/pkg/strconv/#ParseBool). Returns the boolean value represented by `$string`. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
421
+
-_`replace $string $old $new $count`_: Alias for [`strings.Replace`](http://golang.org/pkg/strings/#Replace). Replaces up to `$count` occurences of `$old` with `$new` in `$string`.
422
+
-_`split $string $sep`_: Alias for [`strings.Split`](http://golang.org/pkg/strings/#Split). Splits `$string` into a slice of substrings delimited by `$sep`.
423
+
-_`splitN $string $sep $count`_: Alias for [`strings.SplitN`](https://golang.org/pkg/strings/#SplitN). Splits `$string` into a slice of substrings delimited by `$sep`, with number of substrings returned determined by `$count`.
424
+
-_`toLower $string`_: Alias for [`strings.ToLower`](https://pkg.go.dev/strings#ToLower). Replace capital letters in `$string` to lowercase.
425
+
-_`toUpper $string`_: Alias for [`strings.ToUpper`](https://pkg.go.dev/strings#ToUpper). Replace lowercase letters in `$string` to uppercase.
426
+
427
+
Those have been aliased to Sprig functions with the same behaviour as the original docker-gen function:
428
+
429
+
-_`json $value`_: Alias for Sprig's [`mustToJson`](https://masterminds.github.io/sprig/defaults.html)
430
+
-_`parseJson $string`_: Alias for Sprig's [`mustFromJson`](https://masterminds.github.io/sprig/defaults.html).
431
+
-_`sha1 $string`_: Alias for Sprig's [`sha1sum`](https://masterminds.github.io/sprig/crypto.html).
0 commit comments