1
0
Fork 0

Redirection: permanent move option.

This commit is contained in:
Ludovic Fernandez 2018-01-31 19:10:04 +01:00 committed by Traefiker
parent c944d203fb
commit 58d6681824
83 changed files with 622 additions and 8611 deletions

View file

@ -312,9 +312,12 @@ func (p *Provider) getBuffering(tags []string) *types.Buffering {
}
func (p *Provider) getRedirect(tags []string) *types.Redirect {
permanent := p.getBoolAttribute(label.SuffixFrontendRedirectPermanent, tags, false)
if p.hasAttribute(label.SuffixFrontendRedirectEntryPoint, tags) {
return &types.Redirect{
EntryPoint: p.getAttribute(label.SuffixFrontendRedirectEntryPoint, tags, ""),
Permanent: permanent,
}
}
@ -322,6 +325,7 @@ func (p *Provider) getRedirect(tags []string) *types.Redirect {
return &types.Redirect{
Regex: p.getAttribute(label.SuffixFrontendRedirectRegex, tags, ""),
Replacement: p.getAttribute(label.SuffixFrontendRedirectReplacement, tags, ""),
Permanent: permanent,
}
}

View file

@ -1083,6 +1083,17 @@ func TestProviderGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect tags (permanent)",
tags: []string{
label.TraefikFrontendRedirectEntryPoint + "=https",
label.TraefikFrontendRedirectPermanent + "=true",
},
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect tags",
tags: []string{
@ -1094,6 +1105,19 @@ func TestProviderGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect tags (permanent)",
tags: []string{
label.TraefikFrontendRedirectRegex + "=(.*)",
label.TraefikFrontendRedirectReplacement + "=$1",
label.TraefikFrontendRedirectPermanent + "=true",
},
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {

View file

@ -229,9 +229,12 @@ func getBuffering(container dockerData) *types.Buffering {
}
func getRedirect(container dockerData) *types.Redirect {
permanent := label.GetBoolValue(container.Labels, label.TraefikFrontendRedirectPermanent, false)
if label.Has(container.Labels, label.TraefikFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: label.GetStringValue(container.Labels, label.TraefikFrontendRedirectEntryPoint, ""),
Permanent: permanent,
}
}
@ -240,6 +243,7 @@ func getRedirect(container dockerData) *types.Redirect {
return &types.Redirect{
Regex: label.GetStringValue(container.Labels, label.TraefikFrontendRedirectRegex, ""),
Replacement: label.GetStringValue(container.Labels, label.TraefikFrontendRedirectReplacement, ""),
Permanent: permanent,
}
}

View file

@ -122,6 +122,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectRegex: "nope",
label.TraefikFrontendRedirectReplacement: "nope",
label.TraefikFrontendRedirectPermanent: "true",
label.TraefikFrontendRule: "Host:traefik.io",
label.TraefikFrontendWhitelistSourceRange: "10.10.10.10",
@ -259,6 +260,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
},
},
@ -1221,6 +1223,20 @@ func TestDockerGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
container: containerJSON(
name("test1"),
labels(map[string]string{
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectPermanent: "true",
}),
),
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
container: containerJSON(
@ -1235,6 +1251,22 @@ func TestDockerGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect tags (permanent)",
container: containerJSON(
name("test1"),
labels(map[string]string{
label.TraefikFrontendRedirectRegex: "(.*)",
label.TraefikFrontendRedirectReplacement: "$1",
label.TraefikFrontendRedirectPermanent: "true",
}),
),
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {

View file

@ -100,9 +100,12 @@ func getServicePort(container dockerData, serviceName string) string {
func getServiceRedirect(container dockerData, serviceName string) *types.Redirect {
serviceLabels := getServiceLabels(container, serviceName)
permanent := getServiceBoolValue(container, serviceLabels, label.SuffixFrontendRedirectPermanent, false)
if hasStrictServiceLabel(serviceLabels, label.SuffixFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: getStrictServiceStringValue(serviceLabels, label.SuffixFrontendRedirectEntryPoint, label.DefaultFrontendRedirectEntryPoint),
Permanent: permanent,
}
}
@ -111,6 +114,7 @@ func getServiceRedirect(container dockerData, serviceName string) *types.Redirec
return &types.Redirect{
Regex: getStrictServiceStringValue(serviceLabels, label.SuffixFrontendRedirectRegex, ""),
Replacement: getStrictServiceStringValue(serviceLabels, label.SuffixFrontendRedirectReplacement, ""),
Permanent: permanent,
}
}

View file

@ -86,6 +86,7 @@ func TestDockerServiceBuildConfiguration(t *testing.T) {
label.Prefix + "service." + label.SuffixFrontendRedirectEntryPoint: "https",
label.Prefix + "service." + label.SuffixFrontendRedirectRegex: "nope",
label.Prefix + "service." + label.SuffixFrontendRedirectReplacement: "nope",
label.Prefix + "service." + label.SuffixFrontendRedirectPermanent: "true",
label.Prefix + "service." + label.SuffixFrontendWhitelistSourceRange: "10.10.10.10",
label.Prefix + "service." + label.SuffixFrontendRequestHeaders: "Access-Control-Allow-Methods:POST,GET,OPTIONS || Content-type: application/json; charset=utf-8",
@ -218,6 +219,7 @@ func TestDockerServiceBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
Routes: map[string]types.Route{

View file

@ -212,16 +212,21 @@ func getServers(instances []ecsInstance) map[string]types.Server {
}
func getRedirect(instance ecsInstance) *types.Redirect {
permanent := getBoolValue(instance, label.TraefikFrontendRedirectPermanent, false)
if hasLabel(instance, label.TraefikFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: getStringValue(instance, label.TraefikFrontendRedirectEntryPoint, ""),
Permanent: permanent,
}
}
if hasLabel(instance, label.TraefikFrontendRedirectRegex) &&
hasLabel(instance, label.TraefikFrontendRedirectReplacement) {
return &types.Redirect{
Regex: getStringValue(instance, label.TraefikFrontendRedirectRegex, ""),
Replacement: getStringValue(instance, label.TraefikFrontendRedirectReplacement, ""),
Permanent: permanent,
}
}

View file

@ -150,6 +150,7 @@ func TestBuildConfiguration(t *testing.T) {
label.TraefikFrontendRedirectEntryPoint: aws.String("https"),
label.TraefikFrontendRedirectRegex: aws.String("nope"),
label.TraefikFrontendRedirectReplacement: aws.String("nope"),
label.TraefikFrontendRedirectPermanent: aws.String("true"),
label.TraefikFrontendRule: aws.String("Host:traefik.io"),
label.TraefikFrontendWhitelistSourceRange: aws.String("10.10.10.10"),
@ -333,6 +334,7 @@ func TestBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
},
},
@ -1152,6 +1154,20 @@ func TestGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
instance: ecsInstance{
containerDefinition: &ecs.ContainerDefinition{
DockerLabels: map[string]*string{
label.TraefikFrontendRedirectEntryPoint: aws.String("https"),
label.TraefikFrontendRedirectPermanent: aws.String("true"),
}},
},
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
instance: ecsInstance{
@ -1166,6 +1182,22 @@ func TestGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect tags (permanent)",
instance: ecsInstance{
containerDefinition: &ecs.ContainerDefinition{
DockerLabels: map[string]*string{
label.TraefikFrontendRedirectRegex: aws.String("(.*)"),
label.TraefikFrontendRedirectReplacement: aws.String("$1"),
label.TraefikFrontendRedirectPermanent: aws.String("true"),
}},
},
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {

View file

@ -21,6 +21,7 @@ const (
annotationKubernetesSessionCookieName = "ingress.kubernetes.io/session-cookie-name"
annotationKubernetesRuleType = "ingress.kubernetes.io/rule-type"
annotationKubernetesRedirectEntryPoint = "ingress.kubernetes.io/redirect-entry-point"
annotationKubernetesRedirectPermanent = "ingress.kubernetes.io/redirect-permanent"
annotationKubernetesRedirectRegex = "ingress.kubernetes.io/redirect-regex"
annotationKubernetesRedirectReplacement = "ingress.kubernetes.io/redirect-replacement"
annotationKubernetesMaxConnAmount = "ingress.kubernetes.io/max-conn-amount"

View file

@ -456,10 +456,13 @@ func shouldProcessIngress(ingressClass string) bool {
}
func getFrontendRedirect(i *v1beta1.Ingress) *types.Redirect {
permanent := getBoolValue(i.Annotations, annotationKubernetesRedirectPermanent, false)
redirectEntryPoint := getStringValue(i.Annotations, annotationKubernetesRedirectEntryPoint, "")
if len(redirectEntryPoint) > 0 {
return &types.Redirect{
EntryPoint: redirectEntryPoint,
Permanent: permanent,
}
}
@ -469,6 +472,7 @@ func getFrontendRedirect(i *v1beta1.Ingress) *types.Redirect {
return &types.Redirect{
Regex: redirectRegex,
Replacement: redirectReplacement,
Permanent: permanent,
}
}

View file

@ -33,6 +33,7 @@ const (
pathFrontendRedirectEntryPoint = "/redirect/entrypoint"
pathFrontendRedirectRegex = "/redirect/regex"
pathFrontendRedirectReplacement = "/redirect/replacement"
pathFrontendRedirectPermanent = "/redirect/permanent"
pathFrontendErrorPages = "/errors/"
pathFrontendErrorPagesBackend = "/backend"
pathFrontendErrorPagesQuery = "/query"

View file

@ -108,9 +108,12 @@ func (p *Provider) getStickinessCookieName(rootPath string) string {
}
func (p *Provider) getRedirect(rootPath string) *types.Redirect {
permanent := p.getBool(false, rootPath, pathFrontendRedirectPermanent)
if p.has(rootPath, pathFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: p.get("", rootPath, pathFrontendRedirectEntryPoint),
Permanent: permanent,
}
}
@ -118,6 +121,7 @@ func (p *Provider) getRedirect(rootPath string) *types.Redirect {
return &types.Redirect{
Regex: p.get("", rootPath, pathFrontendRedirectRegex),
Replacement: p.get("", rootPath, pathFrontendRedirectReplacement),
Permanent: permanent,
}
}

View file

@ -95,6 +95,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
withPair(pathFrontendRedirectEntryPoint, "https"),
withPair(pathFrontendRedirectRegex, "nope"),
withPair(pathFrontendRedirectReplacement, "nope"),
withPair(pathFrontendRedirectPermanent, "true"),
withErrorPage("foo", "error", "/test1", "500-501, 503-599"),
withErrorPage("bar", "error", "/test2", "400-405"),
withRateLimit("client.ip",
@ -186,6 +187,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
BasicAuth: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
Redirect: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
Errors: map[string]*types.ErrorPage{
"foo": {
@ -1044,6 +1046,18 @@ func TestProviderGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should use entry point when entry point key is valued in the store (permanent)",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withPair(pathFrontendRedirectEntryPoint, "https"),
withPair(pathFrontendRedirectPermanent, "true"))),
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should use regex when regex keys are valued in the store",
rootPath: "traefik/frontends/foo",
@ -1056,6 +1070,20 @@ func TestProviderGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should use regex when regex keys are valued in the store (permanent)",
rootPath: "traefik/frontends/foo",
kvPairs: filler("traefik",
frontend("foo",
withPair(pathFrontendRedirectRegex, "(.*)"),
withPair(pathFrontendRedirectReplacement, "$1"),
withPair(pathFrontendRedirectPermanent, "true"))),
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
{
desc: "should only use entry point when entry point and regex base are valued in the store",
rootPath: "traefik/frontends/foo",

View file

@ -62,6 +62,7 @@ const (
SuffixFrontendRedirectEntryPoint = "frontend.redirect.entryPoint"
SuffixFrontendRedirectRegex = "frontend.redirect.regex"
SuffixFrontendRedirectReplacement = "frontend.redirect.replacement"
SuffixFrontendRedirectPermanent = "frontend.redirect.permanent"
SuffixFrontendRule = "frontend.rule"
SuffixFrontendRuleType = "frontend.rule.type"
SuffixFrontendWhitelistSourceRange = "frontend.whitelistSourceRange"
@ -102,6 +103,7 @@ const (
TraefikFrontendRedirectEntryPoint = Prefix + SuffixFrontendRedirectEntryPoint
TraefikFrontendRedirectRegex = Prefix + SuffixFrontendRedirectRegex
TraefikFrontendRedirectReplacement = Prefix + SuffixFrontendRedirectReplacement
TraefikFrontendRedirectPermanent = Prefix + SuffixFrontendRedirectPermanent
TraefikFrontendRule = Prefix + SuffixFrontendRule
TraefikFrontendRuleType = Prefix + SuffixFrontendRuleType // k8s only
TraefikFrontendWhitelistSourceRange = Prefix + SuffixFrontendWhitelistSourceRange

View file

@ -501,16 +501,21 @@ func (p *Provider) getServers(application marathon.Application, serviceName stri
func getRedirect(application marathon.Application, serviceName string) *types.Redirect {
labels := getLabels(application, serviceName)
permanent := label.GetBoolValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectPermanent), false)
if label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectEntryPoint)) {
return &types.Redirect{
EntryPoint: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectEntryPoint), ""),
Permanent: permanent,
}
}
if label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectRegex)) &&
label.Has(labels, getLabelName(serviceName, label.SuffixFrontendRedirectReplacement)) {
return &types.Redirect{
Regex: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectRegex), ""),
Replacement: label.GetStringValue(labels, getLabelName(serviceName, label.SuffixFrontendRedirectReplacement), ""),
Permanent: permanent,
}
}

View file

@ -204,6 +204,7 @@ func TestBuildConfigurationNonAPIErrors(t *testing.T) {
withLabel(label.TraefikFrontendRedirectEntryPoint, "https"),
withLabel(label.TraefikFrontendRedirectRegex, "nope"),
withLabel(label.TraefikFrontendRedirectReplacement, "nope"),
withLabel(label.TraefikFrontendRedirectPermanent, "true"),
withLabel(label.TraefikFrontendRule, "Host:traefik.io"),
withLabel(label.TraefikFrontendWhitelistSourceRange, "10.10.10.10"),
@ -342,6 +343,7 @@ func TestBuildConfigurationNonAPIErrors(t *testing.T) {
},
Redirect: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
},
@ -524,6 +526,7 @@ func TestBuildConfigurationServicesNonAPIErrors(t *testing.T) {
withServiceLabel(label.TraefikFrontendRedirectEntryPoint, "https", "containous"),
withServiceLabel(label.TraefikFrontendRedirectRegex, "nope", "containous"),
withServiceLabel(label.TraefikFrontendRedirectReplacement, "nope", "containous"),
withServiceLabel(label.TraefikFrontendRedirectPermanent, "true", "containous"),
withServiceLabel(label.TraefikFrontendRule, "Host:traefik.io", "containous"),
withServiceLabel(label.TraefikFrontendWhitelistSourceRange, "10.10.10.10", "containous"),
@ -661,6 +664,7 @@ func TestBuildConfigurationServicesNonAPIErrors(t *testing.T) {
},
Redirect: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
},
@ -1698,6 +1702,18 @@ func TestGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
application: application(
appPorts(80),
withLabel(label.TraefikFrontendRedirectEntryPoint, "https"),
withLabel(label.TraefikFrontendRedirectPermanent, "true"),
),
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
application: application(
@ -1748,6 +1764,21 @@ func TestGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect labels on service (permanent)",
application: application(
appPorts(80),
withLabel(label.Prefix+"containous."+label.SuffixFrontendRedirectRegex, "(.*)"),
withLabel(label.Prefix+"containous."+label.SuffixFrontendRedirectReplacement, "$1"),
withLabel(label.Prefix+"containous."+label.SuffixFrontendRedirectPermanent, "true"),
),
serviceName: "containous",
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {

View file

@ -338,9 +338,12 @@ func (p *Provider) getServers(tasks []state.Task) map[string]types.Server {
}
func getRedirect(task state.Task) *types.Redirect {
permanent := getBoolValue(task, label.TraefikFrontendRedirectPermanent, false)
if hasLabel(task, label.TraefikFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: getStringValue(task, label.TraefikFrontendRedirectEntryPoint, ""),
Permanent: permanent,
}
}
@ -349,6 +352,7 @@ func getRedirect(task state.Task) *types.Redirect {
return &types.Redirect{
Regex: getStringValue(task, label.TraefikFrontendRedirectRegex, ""),
Replacement: getStringValue(task, label.TraefikFrontendRedirectReplacement, ""),
Permanent: permanent,
}
}

View file

@ -146,6 +146,7 @@ func TestBuildConfiguration(t *testing.T) {
withLabel(label.TraefikFrontendRedirectEntryPoint, "https"),
withLabel(label.TraefikFrontendRedirectRegex, "nope"),
withLabel(label.TraefikFrontendRedirectReplacement, "nope"),
withLabel(label.TraefikFrontendRedirectPermanent, "true"),
withLabel(label.TraefikFrontendRule, "Host:traefik.io"),
withLabel(label.TraefikFrontendWhitelistSourceRange, "10.10.10.10"),
@ -283,6 +284,7 @@ func TestBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
},
},
@ -991,6 +993,20 @@ func TestGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
task: aTask("ID1",
withLabel(label.TraefikFrontendRedirectEntryPoint, "https"),
withLabel(label.TraefikFrontendRedirectPermanent, "true"),
withIP("10.10.10.10"),
withInfo("name1", withPorts(withPort("TCP", 80, "WEB"))),
withDefaultStatus(),
),
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
task: aTask("ID1",
@ -1005,6 +1021,22 @@ func TestGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect labels (permanent)",
task: aTask("ID1",
withLabel(label.TraefikFrontendRedirectRegex, "(.*)"),
withLabel(label.TraefikFrontendRedirectReplacement, "$1"),
withLabel(label.TraefikFrontendRedirectPermanent, "true"),
withIP("10.10.10.10"),
withInfo("name1", withPorts(withPort("TCP", 80, "WEB"))),
withDefaultStatus(),
),
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {

View file

@ -273,9 +273,12 @@ func getServers(service rancherData) map[string]types.Server {
}
func getRedirect(service rancherData) *types.Redirect {
permanent := label.GetBoolValue(service.Labels, label.TraefikFrontendRedirectPermanent, false)
if label.Has(service.Labels, label.TraefikFrontendRedirectEntryPoint) {
return &types.Redirect{
EntryPoint: label.GetStringValue(service.Labels, label.TraefikFrontendRedirectEntryPoint, ""),
Permanent: permanent,
}
}
@ -284,6 +287,7 @@ func getRedirect(service rancherData) *types.Redirect {
return &types.Redirect{
Regex: label.GetStringValue(service.Labels, label.TraefikFrontendRedirectRegex, ""),
Replacement: label.GetStringValue(service.Labels, label.TraefikFrontendRedirectReplacement, ""),
Permanent: permanent,
}
}

View file

@ -64,6 +64,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectRegex: "nope",
label.TraefikFrontendRedirectReplacement: "nope",
label.TraefikFrontendRedirectPermanent: "true",
label.TraefikFrontendRule: "Host:traefik.io",
label.TraefikFrontendWhitelistSourceRange: "10.10.10.10",
@ -199,6 +200,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
},
},
@ -1041,6 +1043,21 @@ func TestGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
service: rancherData{
Labels: map[string]string{
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectPermanent: "true",
},
Health: "healthy",
State: "active",
},
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
service: rancherData{
@ -1056,6 +1073,23 @@ func TestGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect labels (permanent)",
service: rancherData{
Labels: map[string]string{
label.TraefikFrontendRedirectRegex: "(.*)",
label.TraefikFrontendRedirectReplacement: "$1",
label.TraefikFrontendRedirectPermanent: "true",
},
Health: "healthy",
State: "active",
},
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {