Annotations: Reload on custom header changes. (#12653)

Co-authored-by: jgoelen <jurgen.goelen@vlaanderen.be>
This commit is contained in:
k8s-infra-cherrypick-robot 2025-01-09 14:28:32 -08:00 committed by GitHub
parent 96cda8d697
commit 5802ecc4b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 2 deletions

View file

@ -18,6 +18,7 @@ package customheaders
import (
"fmt"
"reflect"
"regexp"
"k8s.io/klog/v2"
@ -35,6 +36,18 @@ type Config struct {
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 (
headerRegexp = regexp.MustCompile(`^[a-zA-Z\d\-_]+$`)
valueRegexp = regexp.MustCompile(`^[a-zA-Z\d_ :;.,\\/"'?!(){}\[\]@<>=\-+*#$&\x60|~^%]+$`)