refactor: enhance template function readability.
This commit is contained in:
parent
81626eef38
commit
5acee9e11d
1 changed files with 19 additions and 16 deletions
|
@ -15,22 +15,16 @@ import (
|
||||||
// buildConfiguration fills the config template with the given instances
|
// buildConfiguration fills the config template with the given instances
|
||||||
func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) {
|
func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) {
|
||||||
var ecsFuncMap = template.FuncMap{
|
var ecsFuncMap = template.FuncMap{
|
||||||
"filterFrontends": filterFrontends,
|
// Backend functions
|
||||||
"getFrontendRule": p.getFrontendRule,
|
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
|
||||||
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
|
"getHost": getHost,
|
||||||
|
"getPort": getPort,
|
||||||
|
"getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight),
|
||||||
"hasLoadBalancerLabel": hasLoadBalancerLabel,
|
"hasLoadBalancerLabel": hasLoadBalancerLabel,
|
||||||
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
||||||
"getSticky": getSticky,
|
"getSticky": getSticky,
|
||||||
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
|
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
|
||||||
"getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName),
|
"getStickinessCookieName": getFuncFirstStringValue(label.TraefikBackendLoadBalancerStickinessCookieName, label.DefaultBackendLoadbalancerStickinessCookieName),
|
||||||
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
|
|
||||||
"getHost": getHost,
|
|
||||||
"getPort": getPort,
|
|
||||||
"getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight),
|
|
||||||
"getPassHostHeader": getFuncStringValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
|
||||||
"getPassTLSCert": getFuncBoolValue(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
|
||||||
"getPriority": getFuncStringValue(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
|
||||||
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
|
|
||||||
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
|
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
|
||||||
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
||||||
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
||||||
|
@ -40,12 +34,21 @@ func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types
|
||||||
"hasMaxConnLabels": hasMaxConnLabels,
|
"hasMaxConnLabels": hasMaxConnLabels,
|
||||||
"getMaxConnAmount": getFuncFirstInt64Value(label.TraefikBackendMaxConnAmount, math.MaxInt64),
|
"getMaxConnAmount": getFuncFirstInt64Value(label.TraefikBackendMaxConnAmount, math.MaxInt64),
|
||||||
"getMaxConnExtractorFunc": getFuncFirstStringValue(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
|
"getMaxConnExtractorFunc": getFuncFirstStringValue(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
|
||||||
|
|
||||||
|
// Frontend functions
|
||||||
|
"filterFrontends": filterFrontends,
|
||||||
|
"getFrontendRule": p.getFrontendRule,
|
||||||
|
"getPassHostHeader": getFuncStringValue(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||||
|
"getPassTLSCert": getFuncBoolValue(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||||
|
"getPriority": getFuncStringValue(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||||
|
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||||
|
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||||
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
|
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
|
||||||
"hasRedirect": hasRedirect,
|
"hasRedirect": hasRedirect,
|
||||||
"getRedirectEntryPoint": getFuncStringValue(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
"getRedirectEntryPoint": getFuncStringValue(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
||||||
"getRedirectRegex": getFuncStringValue(label.TraefikFrontendRedirectRegex, ""),
|
"getRedirectRegex": getFuncStringValue(label.TraefikFrontendRedirectRegex, ""),
|
||||||
"getRedirectReplacement": getFuncStringValue(label.TraefikFrontendRedirectReplacement, ""),
|
"getRedirectReplacement": getFuncStringValue(label.TraefikFrontendRedirectReplacement, ""),
|
||||||
|
// Headers
|
||||||
"hasRequestHeaders": hasFuncLabel(label.TraefikFrontendRequestHeaders),
|
"hasRequestHeaders": hasFuncLabel(label.TraefikFrontendRequestHeaders),
|
||||||
"getRequestHeaders": getFuncMapValue(label.TraefikFrontendRequestHeaders),
|
"getRequestHeaders": getFuncMapValue(label.TraefikFrontendRequestHeaders),
|
||||||
"hasResponseHeaders": hasFuncLabel(label.TraefikFrontendResponseHeaders),
|
"hasResponseHeaders": hasFuncLabel(label.TraefikFrontendResponseHeaders),
|
||||||
|
|
Loading…
Reference in a new issue