1
0
Fork 0

Merge tag 'v1.7.4' into master

This commit is contained in:
Fernandez Ludovic 2018-10-30 12:34:00 +01:00
commit d3ae88f108
154 changed files with 4356 additions and 1285 deletions

44
types/dns_resolvers.go Normal file
View file

@ -0,0 +1,44 @@
package types
import (
"fmt"
"strings"
)
// DNSResolvers is a list of DNSes that we will try to resolve the challenged FQDN against
type DNSResolvers []string
// String is the method to format the flag's value, part of the flag.Value interface.
// The String method's output will be used in diagnostics.
func (r *DNSResolvers) String() string {
return strings.Join(*r, ",")
}
// Set is the method to set the flag value, part of the flag.Value interface.
// Set's argument is a string to be parsed to set the flag.
// It's a comma-separated list, so we split it.
func (r *DNSResolvers) Set(value string) error {
entryPoints := strings.Split(value, ",")
if len(entryPoints) == 0 {
return fmt.Errorf("wrong DNSResolvers format: %s", value)
}
for _, entryPoint := range entryPoints {
*r = append(*r, entryPoint)
}
return nil
}
// Get return the DNSResolvers list
func (r *DNSResolvers) Get() interface{} {
return *r
}
// SetValue sets the DNSResolvers list
func (r *DNSResolvers) SetValue(val interface{}) {
*r = val.(DNSResolvers)
}
// Type is type of the struct
func (r *DNSResolvers) Type() string {
return "dnsresolvers"
}

View file

@ -88,6 +88,11 @@ func (f *FieldNames) Get() interface{} {
// Set's argument is a string to be parsed to set the flag.
// It's a space-separated list, so we split it.
func (f *FieldNames) Set(value string) error {
// When arguments are passed through YAML, escaped double quotes
// might be added to this string, and they would break the last
// key/value pair. This ensures the string is clean.
value = strings.Trim(value, "\"")
fields := strings.Fields(value)
for _, field := range fields {
@ -123,6 +128,11 @@ func (f *FieldHeaderNames) Get() interface{} {
// Set's argument is a string to be parsed to set the flag.
// It's a space-separated list, so we split it.
func (f *FieldHeaderNames) Set(value string) error {
// When arguments are passed through YAML, escaped double quotes
// might be added to this string, and they would break the last
// key/value pair. This ensures the string is clean.
value = strings.Trim(value, "\"")
fields := strings.Fields(value)
for _, field := range fields {

View file

@ -301,6 +301,14 @@ func TestFieldsHeadersNamesSet(t *testing.T) {
"X-HEADER-2": "bar",
},
},
{
desc: "Two values separated by space with escaped double quotes should return FieldNames of size 2",
value: "\"X-HEADER-1=foo X-HEADER-2=bar\"",
expected: &FieldHeaderNames{
"X-HEADER-1": "foo",
"X-HEADER-2": "bar",
},
},
}
for _, test := range testCases {

View file

@ -23,12 +23,18 @@ import (
// Backend holds backend configuration.
type Backend struct {
Servers map[string]Server `json:"servers,omitempty"`
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
MaxConn *MaxConn `json:"maxConn,omitempty"`
HealthCheck *HealthCheck `json:"healthCheck,omitempty"`
Buffering *Buffering `json:"buffering,omitempty"`
Servers map[string]Server `json:"servers,omitempty"`
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
MaxConn *MaxConn `json:"maxConn,omitempty"`
HealthCheck *HealthCheck `json:"healthCheck,omitempty"`
Buffering *Buffering `json:"buffering,omitempty"`
ResponseForwarding *ResponseForwarding `json:"forwardingResponse,omitempty"`
}
// ResponseForwarding holds configuration for the forward of the response
type ResponseForwarding struct {
FlushInterval string `json:"flushInterval,omitempty"`
}
// MaxConn holds maximum connection configuration