SuccessChanges

Summary

  1. Router template optimization (commit: 2ed8547) (details)
Commit 2ed8547c7bac9d86d503bc6f1374096ffa05a31b by yhlou
Router template optimization
This PR introduces some optimizations to router template files, which
simplify the structure of the template file, improve compatibility for
future HAPROXY versions, and improve maintainancibility of
template-related codes. Major optimizations include:
1. Move template helper functions, as well as the mapping structure,
into a new .go file named `template_helper.go` 2. Replace the
non-standard form `listen stats :<port>` which is forbidden by HAPROXY
1.7.0+ with the standard form `listen stats` and `bind :<port>`. 3.
Introduce two new helper functions: `firstMatch` and `isTrue`.
`firstMatch` matches the regexp given in the first argument with the
following string arguments and returns the first matched string, while
`isTrue` is a proxy for Go's `strconv.ParseBool`. 4. Change the `env`
function to take variable args: `env(name, def...)`. It accepts multiple
default values, but only the first non-empty default value takes effect
if the environment variable is not defined. If no default value is
given, or all default values are empty, then it treats
`""` as the default value. 5. Eliminate many unnecessary `{{if}}`s from
the template file through the introduction of `firstMatch` function. The
result is the size of the template file is significantly reduced.
(commit: 2ed8547)
The file was modifiedpkg/router/template/router_test.go (diff)
The file was modifiedimages/router/haproxy/conf/haproxy-config.template (diff)
The file was addedpkg/router/template/template_helper_test.go
The file was modifiedpkg/router/template/router.go (diff)
The file was addedpkg/router/template/template_helper.go
The file was modifiedpkg/router/template/plugin.go (diff)