Allow configuring server URLs with label providers
This commit is contained in:
parent
b0a72960bc
commit
95dd17e020
18 changed files with 924 additions and 48 deletions
|
@ -270,17 +270,13 @@ func (r *ResponseForwarding) SetDefaults() {
|
|||
|
||||
// Server holds the server configuration.
|
||||
type Server struct {
|
||||
URL string `json:"url,omitempty" toml:"url,omitempty" yaml:"url,omitempty" label:"-"`
|
||||
Weight *int `json:"weight,omitempty" toml:"weight,omitempty" yaml:"weight,omitempty" label:"weight" export:"true"`
|
||||
PreservePath bool `json:"preservePath,omitempty" toml:"preservePath,omitempty" yaml:"preservePath,omitempty" label:"-" export:"true"`
|
||||
URL string `json:"url,omitempty" toml:"url,omitempty" yaml:"url,omitempty"`
|
||||
Weight *int `json:"weight,omitempty" toml:"weight,omitempty" yaml:"weight,omitempty" export:"true"`
|
||||
PreservePath bool `json:"preservePath,omitempty" toml:"preservePath,omitempty" yaml:"preservePath,omitempty" export:"true"`
|
||||
Fenced bool `json:"fenced,omitempty" toml:"-" yaml:"-" label:"-" file:"-" kv:"-"`
|
||||
Scheme string `json:"-" toml:"-" yaml:"-" file:"-"`
|
||||
Port string `json:"-" toml:"-" yaml:"-" file:"-"`
|
||||
}
|
||||
|
||||
// SetDefaults Default values for a Server.
|
||||
func (s *Server) SetDefaults() {
|
||||
s.Scheme = "http"
|
||||
// Scheme can only be defined with label Providers.
|
||||
Scheme string `json:"-" toml:"-" yaml:"-" file:"-" kv:"-"`
|
||||
Port string `json:"-" toml:"-" yaml:"-" file:"-" kv:"-"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen=true
|
||||
|
|
|
@ -171,6 +171,8 @@ func TestDecodeConfiguration(t *testing.T) {
|
|||
"traefik.http.services.Service0.loadbalancer.healthcheck.followredirects": "true",
|
||||
"traefik.http.services.Service0.loadbalancer.passhostheader": "true",
|
||||
"traefik.http.services.Service0.loadbalancer.responseforwarding.flushinterval": "1s",
|
||||
"traefik.http.services.Service0.loadbalancer.server.url": "foobar",
|
||||
"traefik.http.services.Service0.loadbalancer.server.preservepath": "true",
|
||||
"traefik.http.services.Service0.loadbalancer.server.scheme": "foobar",
|
||||
"traefik.http.services.Service0.loadbalancer.server.port": "8080",
|
||||
"traefik.http.services.Service0.loadbalancer.sticky.cookie.name": "foobar",
|
||||
|
@ -191,6 +193,8 @@ func TestDecodeConfiguration(t *testing.T) {
|
|||
"traefik.http.services.Service1.loadbalancer.healthcheck.followredirects": "true",
|
||||
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
|
||||
"traefik.http.services.Service1.loadbalancer.responseforwarding.flushinterval": "1s",
|
||||
"traefik.http.services.Service1.loadbalancer.server.url": "foobar",
|
||||
"traefik.http.services.Service1.loadbalancer.server.preservepath": "true",
|
||||
"traefik.http.services.Service1.loadbalancer.server.scheme": "foobar",
|
||||
"traefik.http.services.Service1.loadbalancer.server.port": "8080",
|
||||
"traefik.http.services.Service1.loadbalancer.sticky": "false",
|
||||
|
@ -683,8 +687,10 @@ func TestDecodeConfiguration(t *testing.T) {
|
|||
},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
URL: "foobar",
|
||||
PreservePath: true,
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
},
|
||||
},
|
||||
HealthCheck: &dynamic.ServerHealthCheck{
|
||||
|
@ -714,8 +720,10 @@ func TestDecodeConfiguration(t *testing.T) {
|
|||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
URL: "foobar",
|
||||
PreservePath: true,
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
},
|
||||
},
|
||||
HealthCheck: &dynamic.ServerHealthCheck{
|
||||
|
@ -1218,8 +1226,10 @@ func TestEncodeConfiguration(t *testing.T) {
|
|||
},
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
URL: "foobar",
|
||||
PreservePath: true,
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
},
|
||||
},
|
||||
HealthCheck: &dynamic.ServerHealthCheck{
|
||||
|
@ -1247,8 +1257,10 @@ func TestEncodeConfiguration(t *testing.T) {
|
|||
LoadBalancer: &dynamic.ServersLoadBalancer{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
URL: "foobar",
|
||||
PreservePath: true,
|
||||
Scheme: "foobar",
|
||||
Port: "8080",
|
||||
},
|
||||
},
|
||||
HealthCheck: &dynamic.ServerHealthCheck{
|
||||
|
@ -1454,6 +1466,8 @@ func TestEncodeConfiguration(t *testing.T) {
|
|||
"traefik.HTTP.Services.Service0.LoadBalancer.HealthCheck.Timeout": "1000000000",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.PassHostHeader": "true",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.ResponseForwarding.FlushInterval": "1000000000",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.server.URL": "foobar",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.server.PreservePath": "true",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.server.Port": "8080",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.server.Scheme": "foobar",
|
||||
"traefik.HTTP.Services.Service0.LoadBalancer.Sticky.Cookie.Name": "foobar",
|
||||
|
@ -1474,6 +1488,8 @@ func TestEncodeConfiguration(t *testing.T) {
|
|||
"traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Timeout": "1000000000",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.PassHostHeader": "true",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.ResponseForwarding.FlushInterval": "1000000000",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.server.URL": "foobar",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.server.PreservePath": "true",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.server.Port": "8080",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.server.Scheme": "foobar",
|
||||
"traefik.HTTP.Services.Service1.LoadBalancer.ServersTransport": "foobar",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue