feat(marathon): add frontend redirect labels.
This commit is contained in:
parent
edc55aad3c
commit
b4f6bf0f6a
2 changed files with 21 additions and 0 deletions
|
@ -50,6 +50,10 @@ func (p *Provider) buildConfiguration() *types.Configuration {
|
|||
"getServiceNames": getServiceNames,
|
||||
"getServiceNameSuffix": getServiceNameSuffix,
|
||||
"getWhitelistSourceRange": getFuncSliceStringService(label.TraefikFrontendWhitelistSourceRange),
|
||||
"hasRedirect": hasRedirect,
|
||||
"getRedirectEntryPoint": getFuncStringService(label.TraefikFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
|
||||
"getRedirectRegex": getFuncStringService(label.TraefikFrontendRedirectRegex, ""),
|
||||
"getRedirectReplacement": getFuncStringService(label.TraefikFrontendRedirectReplacement, ""),
|
||||
}
|
||||
|
||||
v := url.Values{}
|
||||
|
@ -364,6 +368,16 @@ func retrieveAvailablePorts(application marathon.Application, task marathon.Task
|
|||
return []int{}
|
||||
}
|
||||
|
||||
func hasRedirect(application marathon.Application, serviceName string) bool {
|
||||
labels := getLabels(application, serviceName)
|
||||
|
||||
frep := label.Has(labels, getLabelName(serviceName, label.TraefikFrontendRedirectEntryPoint))
|
||||
frrg := label.Has(labels, getLabelName(serviceName, label.TraefikFrontendRedirectRegex))
|
||||
frrp := label.Has(labels, getLabelName(serviceName, label.TraefikFrontendRedirectReplacement))
|
||||
|
||||
return frep || frrg && frrp
|
||||
}
|
||||
|
||||
// Label functions
|
||||
|
||||
func getLabels(application marathon.Application, serviceName string) map[string]string {
|
||||
|
|
|
@ -72,6 +72,13 @@
|
|||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
{{if hasRedirect $app $serviceName}}
|
||||
[frontends."{{ getFrontendName $app $serviceName }}".redirect]
|
||||
entryPoint = "{{getRedirectEntryPoint $app $serviceName}}"
|
||||
regex = "{{getRedirectRegex $app $serviceName}}"
|
||||
replacement = "{{getRedirectReplacement $app $serviceName}}"
|
||||
{{end}}
|
||||
|
||||
[frontends."{{ getFrontendName $app $serviceName }}".routes."route-host{{$app.ID | replace "/" "-"}}{{getServiceNameSuffix $serviceName }}"]
|
||||
rule = "{{getFrontendRule $app $serviceName}}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue