-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Revise router template functions #5068
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,21 +115,24 @@ The *define* action names the file that will contain the processed template. | |
[cols="2*", options="header"] | ||
|=== | ||
|Function | Meaning | ||
|`*endpointsForAlias(alias ServiceAliasConfig, svc ServiceUnit) []Endpoint*` | Returns the list of valid endpoints. | ||
|`*env(variable, default string) string*` | Tries to get the named environment variable from the pod. Returns the second | ||
argument if the variable cannot be read or is empty. | ||
|`*processEndpointsForAlias(alias ServiceAliasConfig, svc ServiceUnit, action string) []Endpoint*` | | ||
Returns the list of valid endpoints. When action is "shuffle", the order of endpoints is randomized. | ||
|`*env(variable, default ...string) string*` | Tries to get the named environment variable from the pod. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
If it is not defined or empty, it returns the optional second argument. Otherwise, it returns an empty string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of this? "If the value is empty or not defined and one or more optional arguments are provided, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Miciah In practice there are 0 or 1 optional values. The environment variable either has a default or it doesn't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pecameron, ah, if we want to avoid documenting (and committing to) allowing more than 2 parameters, that's fine. Never mind! |
||
|`*matchPattern(pattern, s string) bool*` | The first argument is a string that contains the regular | ||
expression, the second argument is the variable to test. Returns a Boolean value indicating whether the regular | ||
expression provided as the first argument matches the string provided as the second argument. | ||
expression, the second argument is the variable to test. Returns a Boolean value indicating whether | ||
the regular expression provided as the first argument matches the string provided as the second argument. | ||
|`*isInteger(s string) bool*` | Determines if a given variable is an integer. | ||
|`*matchValues(s string, allowedValues ...string) bool*` | Compares a given string to a list of allowed strings. | ||
|`*genSubdomainWildcardRegexp(hostname, path string, exactPath bool) string*` | Generates a regular expression matching the | ||
subdomain for hosts (and paths) with a wildcard policy. | ||
|`*generateRouteRegexp(hostname, path string, wildcard bool) string*` | Generates a regular expression matching the route | ||
hosts (and paths). The first argument is the host name, the second is the path, | ||
|`*firstMatch(s string, allowedValues ...string) bool*` | Compares a given string to a list of allowed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The first argument of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
strings. Returns first match scanning left to right through the list. | ||
|`*matchValues(s string, allowedValues ...string) bool*` | Compares a given string to a list of allowed | ||
strings. Returns "true" if the string is an allowed value, otherwise returns false. | ||
|`*generateRouteRegexp(hostname, path string, wildcard bool) string*` | Generates a regular expression | ||
matching the route hosts (and paths). The first argument is the host name, the second is the path, | ||
and the third is a wildcard Boolean. | ||
|`*genCertificateHostName(hostname string, wildcard bool) string*` | Generates host name to use for serving/matching | ||
certificates. First argument is the host name and the second is the wildcard Boolean. | ||
|`*genCertificateHostName(hostname string, wildcard bool) string*` | Generates host name to use for | ||
serving/matching certificates. First argument is the host name and the second is the wildcard Boolean. | ||
|`*isTrue(s string) bool*` | Determines if a given variable contains "true". | ||
|=== | ||
|
||
These functions are provided by the HAProxy template router plug-in. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is
endpointsForAlias
considered deprecated now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. It is not currently used.