Use default frontend priority of zero.
This commit is contained in:
parent
14a0d66410
commit
b80ecd51a7
2 changed files with 14 additions and 70 deletions
|
@ -326,7 +326,7 @@ func getRuleForPath(pa v1beta1.HTTPIngressPath, i *v1beta1.Ingress) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) getPriority(path v1beta1.HTTPIngressPath, i *v1beta1.Ingress) int {
|
func (p *Provider) getPriority(path v1beta1.HTTPIngressPath, i *v1beta1.Ingress) int {
|
||||||
priority := len(path.Path)
|
priority := 0
|
||||||
|
|
||||||
priorityRaw, ok := i.Annotations[types.LabelFrontendPriority]
|
priorityRaw, ok := i.Annotations[types.LabelFrontendPriority]
|
||||||
if ok {
|
if ok {
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
package kubernetes
|
package kubernetes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"k8s.io/client-go/pkg/api/v1"
|
"k8s.io/client-go/pkg/api/v1"
|
||||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||||
|
@ -284,7 +282,6 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -297,7 +294,6 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
"foo/namedthing": {
|
"foo/namedthing": {
|
||||||
Backend: "foo/namedthing",
|
Backend: "foo/namedthing",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/namedthing"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/namedthing": {
|
"/namedthing": {
|
||||||
Rule: "PathPrefix:/namedthing",
|
Rule: "PathPrefix:/namedthing",
|
||||||
|
@ -318,12 +314,8 @@ func TestLoadIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRuleType(t *testing.T) {
|
func TestRuleType(t *testing.T) {
|
||||||
|
@ -419,7 +411,6 @@ func TestRuleType(t *testing.T) {
|
||||||
expected := map[string]*types.Frontend{
|
expected := map[string]*types.Frontend{
|
||||||
"host/path": {
|
"host/path": {
|
||||||
Backend: "host/path",
|
Backend: "host/path",
|
||||||
Priority: len("/path"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/path": {
|
"/path": {
|
||||||
Rule: fmt.Sprintf("%s:/path", test.frontendRuleType),
|
Rule: fmt.Sprintf("%s:/path", test.frontendRuleType),
|
||||||
|
@ -431,11 +422,7 @@ func TestRuleType(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(expected, actual) {
|
assert.Equal(t, expected, actual)
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,7 +497,6 @@ func TestGetPassHostHeader(t *testing.T) {
|
||||||
Frontends: map[string]*types.Frontend{
|
Frontends: map[string]*types.Frontend{
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -522,12 +508,8 @@ func TestGetPassHostHeader(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
||||||
|
@ -626,12 +608,8 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadNamespacedIngresses(t *testing.T) {
|
func TestLoadNamespacedIngresses(t *testing.T) {
|
||||||
|
@ -810,7 +788,6 @@ func TestLoadNamespacedIngresses(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -831,12 +808,8 @@ func TestLoadNamespacedIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
|
@ -1048,7 +1021,6 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -1070,7 +1042,6 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
"awesome/quix": {
|
"awesome/quix": {
|
||||||
Backend: "awesome/quix",
|
Backend: "awesome/quix",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/quix"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/quix": {
|
"/quix": {
|
||||||
Rule: "PathPrefix:/quix",
|
Rule: "PathPrefix:/quix",
|
||||||
|
@ -1082,12 +1053,8 @@ func TestLoadMultipleNamespacedIngresses(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHostlessIngress(t *testing.T) {
|
func TestHostlessIngress(t *testing.T) {
|
||||||
|
@ -1159,7 +1126,6 @@ func TestHostlessIngress(t *testing.T) {
|
||||||
Frontends: map[string]*types.Frontend{
|
Frontends: map[string]*types.Frontend{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Backend: "/bar",
|
Backend: "/bar",
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -1168,12 +1134,8 @@ func TestHostlessIngress(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestServiceAnnotations(t *testing.T) {
|
func TestServiceAnnotations(t *testing.T) {
|
||||||
|
@ -1383,7 +1345,6 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -1404,12 +1365,8 @@ func TestServiceAnnotations(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actualJSON, _ := json.Marshal(actual)
|
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIngressAnnotations(t *testing.T) {
|
func TestIngressAnnotations(t *testing.T) {
|
||||||
|
@ -1705,7 +1662,6 @@ func TestIngressAnnotations(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: false,
|
PassHostHeader: false,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -1718,7 +1674,6 @@ func TestIngressAnnotations(t *testing.T) {
|
||||||
"other/stuff": {
|
"other/stuff": {
|
||||||
Backend: "other/stuff",
|
Backend: "other/stuff",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/stuff"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/stuff": {
|
"/stuff": {
|
||||||
Rule: "PathPrefix:/stuff",
|
Rule: "PathPrefix:/stuff",
|
||||||
|
@ -1731,7 +1686,6 @@ func TestIngressAnnotations(t *testing.T) {
|
||||||
"basic/auth": {
|
"basic/auth": {
|
||||||
Backend: "basic/auth",
|
Backend: "basic/auth",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/auth"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/auth": {
|
"/auth": {
|
||||||
Rule: "PathPrefix:/auth",
|
Rule: "PathPrefix:/auth",
|
||||||
|
@ -1749,7 +1703,6 @@ func TestIngressAnnotations(t *testing.T) {
|
||||||
"1.1.1.1/24",
|
"1.1.1.1/24",
|
||||||
"1234:abcd::42/32",
|
"1234:abcd::42/32",
|
||||||
},
|
},
|
||||||
Priority: len("/whitelist-source-range"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/whitelist-source-range": {
|
"/whitelist-source-range": {
|
||||||
Rule: "PathPrefix:/whitelist-source-range",
|
Rule: "PathPrefix:/whitelist-source-range",
|
||||||
|
@ -1770,7 +1723,6 @@ func TestIngressAnnotations(t *testing.T) {
|
||||||
Rule: "Host:rewrite",
|
Rule: "Host:rewrite",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Priority: len("/api"),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1966,7 +1918,6 @@ func TestInvalidPassHostHeaderValue(t *testing.T) {
|
||||||
"foo/bar": {
|
"foo/bar": {
|
||||||
Backend: "foo/bar",
|
Backend: "foo/bar",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
Priority: len("/bar"),
|
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"/bar": {
|
"/bar": {
|
||||||
Rule: "PathPrefix:/bar",
|
Rule: "PathPrefix:/bar",
|
||||||
|
@ -1979,12 +1930,7 @@ func TestInvalidPassHostHeaderValue(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
actualJSON, _ := json.Marshal(actual)
|
assert.Equal(t, expected, actual)
|
||||||
expectedJSON, _ := json.Marshal(expected)
|
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
|
||||||
t.Fatalf("expected %+v, got %+v", string(expectedJSON), string(actualJSON))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKubeAPIErrors(t *testing.T) {
|
func TestKubeAPIErrors(t *testing.T) {
|
||||||
|
@ -2304,9 +2250,7 @@ func TestMissingResources(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
assert.Equal(t, expected, actual)
|
||||||
t.Fatalf("expected\n%v\ngot\n\n%v", spew.Sdump(expected), spew.Sdump(actual))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBasicAuthInTemplate(t *testing.T) {
|
func TestBasicAuthInTemplate(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue