Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added replaceAll support for go templates #5468

Merged
merged 5 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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