fix: default passHostHeader for file provider.
This commit is contained in:
parent
230cd28ac9
commit
48f11900d3
22 changed files with 193 additions and 161 deletions
|
@ -164,8 +164,11 @@ func createLoadBalancerServerHTTP(client Client, namespace string, service v1alp
|
|||
lb.SetDefaults()
|
||||
|
||||
lb.Servers = servers
|
||||
if service.PassHostHeader != nil {
|
||||
lb.PassHostHeader = *service.PassHostHeader
|
||||
|
||||
lb.PassHostHeader = service.PassHostHeader
|
||||
if lb.PassHostHeader == nil {
|
||||
passHostHeader := true
|
||||
lb.PassHostHeader = &passHostHeader
|
||||
}
|
||||
lb.ResponseForwarding = service.ResponseForwarding
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ import (
|
|||
|
||||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
||||
func Int(v int) *int { return &v }
|
||||
func Int(v int) *int { return &v }
|
||||
func Bool(v bool) *bool { return &v }
|
||||
|
||||
func TestLoadIngressRouteTCPs(t *testing.T) {
|
||||
testCases := []struct {
|
||||
|
@ -737,7 +738,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -786,7 +787,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -836,7 +837,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -878,7 +879,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
"default-test.route-77c62dfe9517144aeeaa": {
|
||||
|
@ -891,7 +892,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -943,7 +944,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
"default-test.route-77c62dfe9517144aeeaa-whoami2-8080": {
|
||||
|
@ -956,7 +957,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.4:8080",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1007,7 +1008,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
"default-test.route-77c62dfe9517144aeeaa-whoami2-8080": {
|
||||
|
@ -1020,7 +1021,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.4:8080",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1132,7 +1133,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1190,7 +1191,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1248,7 +1249,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1305,7 +1306,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1351,7 +1352,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1397,7 +1398,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1435,7 +1436,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1472,7 +1473,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "https://10.10.0.6:8443",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1509,7 +1510,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "https://10.10.0.8:8443",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1584,7 +1585,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1620,7 +1621,7 @@ func TestLoadIngressRoutes(t *testing.T) {
|
|||
URL: "http://10.10.0.2:80",
|
||||
},
|
||||
},
|
||||
PassHostHeader: false,
|
||||
PassHostHeader: Bool(false),
|
||||
ResponseForwarding: &dynamic.ResponseForwarding{FlushInterval: "10s"},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -248,7 +248,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
|
|||
return &dynamic.Service{
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
Servers: servers,
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: func(v bool) *bool { return &v }(true),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import (
|
|||
|
||||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
||||
func Bool(v bool) *bool { return &v }
|
||||
|
||||
func TestLoadConfigurationFromIngresses(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
|
@ -51,7 +53,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -85,7 +87,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -119,7 +121,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -149,7 +151,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -178,7 +180,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-example-com-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
|
@ -209,7 +211,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -243,7 +245,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -277,7 +279,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -318,7 +320,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -363,7 +365,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -376,7 +378,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
"testing-service2-8082": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.2:8080",
|
||||
|
@ -429,7 +431,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
@ -459,7 +461,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
|
@ -489,7 +491,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-tchouk": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
|
@ -519,7 +521,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-tchouk": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
|
@ -553,7 +555,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-tchouk": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
|
@ -566,7 +568,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
"testing-service1-carotte": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8090",
|
||||
|
@ -600,7 +602,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-tchouk": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8089",
|
||||
|
@ -613,7 +615,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
},
|
||||
"toto-service1-tchouk": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:8089",
|
||||
|
@ -665,7 +667,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-8080": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://traefik.wtf:8080",
|
||||
|
@ -697,7 +699,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-example-com-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.11.0.1:80",
|
||||
|
@ -734,7 +736,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-443": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
|
@ -764,7 +766,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-8443": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
|
@ -795,7 +797,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-8443": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "https://10.10.0.1:8443",
|
||||
|
@ -826,7 +828,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"default-backend": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.30.0.1:8080",
|
||||
|
@ -856,7 +858,7 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
|
|||
Services: map[string]*dynamic.Service{
|
||||
"testing-service1-80": {
|
||||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
PassHostHeader: true,
|
||||
PassHostHeader: Bool(true),
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://10.10.0.1:8080",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue