Skip to content

Commit

Permalink
Added replaceAll support for go templates (#5468)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziofiorucci committed May 1, 2024
1 parent 32ef0fc commit 7f19bed
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Helper functions can be used in the Ingress template to parse the values of cust
| ``hasSuffix`` | ``s, suffix string`` | ``bool`` | Tests whether the string ``suffix`` is a suffix of the string ``s``. |
| ``toLower`` | ``s string`` | ``bool`` | Converts all letters in the string ``s`` to their lower case. |
| ``toUpper`` | ``s string`` | ``bool`` | Converts all letters in the string ``s`` to their upper case. |
| ``replaceAll`` | ``s, old, new string`` | ``string`` | Replaces all occurrences of ``old`` with ``new`` in the string ``s``. |
{{% /table %}}

Consider the following custom annotation `custom.nginx.org/allowed-ips`, which expects a comma-separated list of IP addresses:
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version1/template_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ var helperFunctions = template.FuncMap{
"hasSuffix": strings.HasSuffix,
"toLower": strings.ToLower,
"toUpper": strings.ToUpper,
"replaceAll": strings.ReplaceAll,
"makeLocationPath": makeLocationPath,
"makeSecretPath": commonhelpers.MakeSecretPath,
"generateProxySetHeaders": generateProxySetHeaders,
Expand Down
1 change: 1 addition & 0 deletions internal/configs/version2/template_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ var helperFunctions = template.FuncMap{
"hasSuffix": strings.HasSuffix,
"toLower": strings.ToLower,
"toUpper": strings.ToUpper,
"replaceAll": strings.ReplaceAll,
"makeHTTPListener": makeHTTPListener,
"makeHTTPSListener": makeHTTPSListener,
"makeSecretPath": commonhelpers.MakeSecretPath,
Expand Down

0 comments on commit 7f19bed

Please sign in to comment.