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
|
||||
func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types.Configuration, error) {
|
||||
var ecsFuncMap = template.FuncMap{
|
||||
"filterFrontends": filterFrontends,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
// Backend functions
|
||||
"getProtocol": getFuncStringValue(label.TraefikProtocol, label.DefaultProtocol),
|
||||
"getHost": getHost,
|
||||
"getPort": getPort,
|
||||
"getWeight": getFuncStringValue(label.TraefikWeight, label.DefaultWeight),
|
||||
"hasLoadBalancerLabel": hasLoadBalancerLabel,
|
||||
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
||||
"getSticky": getSticky,
|
||||
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
|
||||
"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),
|
||||
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
||||
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
||||
|
@ -40,12 +34,21 @@ func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types
|
|||
"hasMaxConnLabels": hasMaxConnLabels,
|
||||
"getMaxConnAmount": getFuncFirstInt64Value(label.TraefikBackendMaxConnAmount, math.MaxInt64),
|
||||
"getMaxConnExtractorFunc": getFuncFirstStringValue(label.TraefikBackendMaxConnExtractorFunc, label.DefaultBackendMaxconnExtractorFunc),
|
||||
"getWhitelistSourceRange": getFuncSliceString(label.TraefikFrontendWhitelistSourceRange),
|
||||
"hasRedirect": hasRedirect,
|
||||
"getRedirectEntryPoint": getFuncStringValue(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
||||
"getRedirectRegex": getFuncStringValue(label.TraefikFrontendRedirectRegex, ""),
|
||||
"getRedirectReplacement": getFuncStringValue(label.TraefikFrontendRedirectReplacement, ""),
|
||||
|
||||
// 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),
|
||||
"hasRedirect": hasRedirect,
|
||||
"getRedirectEntryPoint": getFuncStringValue(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
||||
"getRedirectRegex": getFuncStringValue(label.TraefikFrontendRedirectRegex, ""),
|
||||
"getRedirectReplacement": getFuncStringValue(label.TraefikFrontendRedirectReplacement, ""),
|
||||
// Headers
|
||||
"hasRequestHeaders": hasFuncLabel(label.TraefikFrontendRequestHeaders),
|
||||
"getRequestHeaders": getFuncMapValue(label.TraefikFrontendRequestHeaders),
|
||||
"hasResponseHeaders": hasFuncLabel(label.TraefikFrontendResponseHeaders),
|
||||
|
|
Loading…
Reference in a new issue