Skip to content

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

Merged
merged 1 commit into from
Aug 3, 2018
Merged

Conversation

pecameron
Copy link

OCP 3.7

PR 12882 refactored the router template functions.
This PR documents the changes.

@pecameron
Copy link
Author

@louyihua @rajatchopra @knobunc PTAL

Copy link

@rajatchopra rajatchopra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impeccable.
/lgtm

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here should be *env(variable string, defaults ...string) string*

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first argument of firstMatch is a regular expression.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@pecameron
Copy link
Author

@louyihua @knobunc PTAL

Copy link
Contributor

@knobunc knobunc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@louyihua
Copy link

LGTM

@@ -115,21 +115,25 @@ 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.
Copy link
Contributor

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?

Copy link
Author

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.

|`*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 string, default ...string) string*` | Tries to get the named environment variable from the pod.
If it is not defined or empty, it returns the optional second argument.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't describe the behaviour when no second argument is given, or when more than two arguments are given.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Otherwise it returns the empty string. Other arguments are ignored.

OCP 3.7

PR 12882 refactored the router template functions.
This PR documents the changes.
@pecameron
Copy link
Author

@Miciah I addressed your questions and updated the PR. endpointsForAlias is in the code and there are no comments about it being deprecated. It is not currently used in the haproxy template. There is no telling if any customers are using it.

@Miciah
Copy link
Contributor

Miciah commented Oct 3, 2017

@pecameron, thanks! Did you push the new changes? I don't see them yet.

Regarding endpointsForAlias, anybody who is using a custom template who has not rebased recently is using the old function. In order not to break custom templates, we should either document that the old function is deprecated (so that people with custom templates know to change to the new function) or commit to retaining the old function indefinitely (in which case we should document that).

This is probably not the best place to discuss it though; is the matter being tracked anywhere?

@pecameron
Copy link
Author

@Miciah PTAL

|`*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.
If it is not defined or empty, it returns the optional second argument. Otherwise, it returns an empty string.
Copy link
Contributor

Choose a reason for hiding this comment

The 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, env returns the first non-empty argument. Otherwise, it returns an empty string."

Copy link
Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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!

@vikram-redhat
Copy link
Contributor

@bfallonf - PTAL - this is quite old so review accordingly.

@bfallonf
Copy link

bfallonf commented Aug 3, 2018

Sorry @pecameron , looks like this one escaped us. I'll merge this and cherry-pick to the right branches, and make a quick followup PR if I need to. Thanks!

@bfallonf
Copy link

bfallonf commented Aug 3, 2018

/cherrypick enterprise-3.11

@openshift-cherrypick-robot

@bfallonf: new pull request created: #11350

In response to this:

/cherrypick enterprise-3.11

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bfallonf
Copy link

bfallonf commented Aug 3, 2018

/cherrypick enterprise-3.10

@openshift-cherrypick-robot

@bfallonf: new pull request created: #11351

In response to this:

/cherrypick enterprise-3.10

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bfallonf
Copy link

bfallonf commented Aug 3, 2018

/cherrypick enterprise-3.9

@openshift-cherrypick-robot

@bfallonf: new pull request created: #11352

In response to this:

/cherrypick enterprise-3.9

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@bfallonf
Copy link

bfallonf commented Aug 3, 2018

/cherrypick enterprise-3.7

@openshift-cherrypick-robot

@bfallonf: new pull request created: #11353

In response to this:

/cherrypick enterprise-3.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants