From ec121e2f2e8a781bc28209391fd3771abd84b8ff Mon Sep 17 00:00:00 2001 From: jgoelen Date: Wed, 31 Jul 2024 08:50:41 +0200 Subject: [PATCH] Add Equal func for customheaders.Config --- internal/ingress/annotations/customheaders/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/ingress/annotations/customheaders/main.go b/internal/ingress/annotations/customheaders/main.go index 774e9c3d3a..bc0ef2eb52 100644 --- a/internal/ingress/annotations/customheaders/main.go +++ b/internal/ingress/annotations/customheaders/main.go @@ -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|~^%]+$`)