Annotations: Reload on custom header changes. (#11709)
This commit is contained in:
parent
69fd353086
commit
29d1e2014b
4 changed files with 29 additions and 2 deletions
|
@ -18,6 +18,7 @@ package customheaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
@ -35,6 +36,18 @@ type Config struct {
|
||||||
Headers map[string]string `json:"headers,omitempty"`
|
Headers map[string]string `json:"headers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Equal tests for equality between two Config types
|
||||||
|
func (c1 *Config) Equal(c2 *Config) bool {
|
||||||
|
if c1 == c2 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if c1 == nil || c2 == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return reflect.DeepEqual(c1.Headers, c2.Headers)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
headerRegexp = regexp.MustCompile(`^[a-zA-Z\d\-_]+$`)
|
headerRegexp = regexp.MustCompile(`^[a-zA-Z\d\-_]+$`)
|
||||||
valueRegexp = regexp.MustCompile(`^[a-zA-Z\d_ :;.,\\/"'?!(){}\[\]@<>=\-+*#$&\x60|~^%]+$`)
|
valueRegexp = regexp.MustCompile(`^[a-zA-Z\d_ :;.,\\/"'?!(){}\[\]@<>=\-+*#$&\x60|~^%]+$`)
|
||||||
|
|
|
@ -467,6 +467,10 @@ func (l1 *Location) Equal(l2 *Location) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !l1.CustomHeaders.Equal(&l2.CustomHeaders) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -302,7 +302,12 @@
|
||||||
"validationDepth": 0
|
"validationDepth": 0
|
||||||
},
|
},
|
||||||
"use-port-in-redirects": false,
|
"use-port-in-redirects": false,
|
||||||
"configuration-snippet": ""
|
"configuration-snippet": "",
|
||||||
|
"customHeaders": {
|
||||||
|
"headers": {
|
||||||
|
"Server": "HAL9000"
|
||||||
|
}
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
"hostname": "dev.mycompany.com",
|
"hostname": "dev.mycompany.com",
|
||||||
|
|
|
@ -302,7 +302,12 @@
|
||||||
"validationDepth": 0
|
"validationDepth": 0
|
||||||
},
|
},
|
||||||
"use-port-in-redirects": false,
|
"use-port-in-redirects": false,
|
||||||
"configuration-snippet": ""
|
"configuration-snippet": "",
|
||||||
|
"customHeaders": {
|
||||||
|
"headers": {
|
||||||
|
"Server": "HAL9000"
|
||||||
|
}
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
"hostname": "dev.mycompany.com",
|
"hostname": "dev.mycompany.com",
|
||||||
|
|
Loading…
Reference in a new issue