Skip to content

Commit

Permalink
Add Equal func for customheaders.Config
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoelen authored and k8s-infra-cherrypick-robot committed Jan 9, 2025
1 parent 614767a commit ec121e2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/ingress/annotations/customheaders/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package customheaders

import (
"fmt"
"reflect"
"regexp"

"k8s.io/klog/v2"
Expand All @@ -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|~^%]+$`)
Expand Down

0 comments on commit ec121e2

Please sign in to comment.