fix: do not expose vars

This commit is contained in:
ThameezBo 2024-05-15 14:25:03 +02:00
parent fdb2475892
commit 4fcc726863
No known key found for this signature in database
GPG Key ID: 90D87376195CD422
2 changed files with 9 additions and 9 deletions

View File

@ -44,10 +44,10 @@ import (
const (
gatewayGroup = "gateway.networking.k8s.io"
gatewayKind = "Gateway"
// GatewayAPIDualstackAnnotationKey is the annotation used for determining if a Gateway Route is dualstack
GatewayAPIDualstackAnnotationKey = "external-dns.alpha.kubernetes.io/dualstack"
// GatewayAPIDualstackAnnotationValue is the value of the Gateway Route dualstack annotation that indicates it is dualstack
GatewayAPIDualstackAnnotationValue = "true"
// gatewayAPIDualstackAnnotationKey is the annotation used for determining if a Gateway Route is dualstack
gatewayAPIDualstackAnnotationKey = "external-dns.alpha.kubernetes.io/dualstack"
// gatewayAPIDualstackAnnotationValue is the value of the Gateway Route dualstack annotation that indicates it is dualstack
gatewayAPIDualstackAnnotationValue = "true"
)
type gatewayRoute interface {
@ -616,8 +616,8 @@ func selectorsEqual(a, b labels.Selector) bool {
}
func setDualstackLabel(rt gatewayRoute, endpoints []*endpoint.Endpoint) {
val, ok := rt.Metadata().Annotations[GatewayAPIDualstackAnnotationKey]
if ok && val == GatewayAPIDualstackAnnotationValue {
val, ok := rt.Metadata().Annotations[gatewayAPIDualstackAnnotationKey]
if ok && val == gatewayAPIDualstackAnnotationValue {
log.Debugf("Adding dualstack label to GatewayRoute %s/%s.", rt.Metadata().Namespace, rt.Metadata().Name)
for _, ep := range endpoints {
ep.Labels[endpoint.DualstackLabelKey] = "true"

View File

@ -259,17 +259,17 @@ func TestDualStackLabel(t *testing.T) {
},
{
desc: "correct-annotation-key-and-value",
in: map[string]string{GatewayAPIDualstackAnnotationKey: GatewayAPIDualstackAnnotationValue},
in: map[string]string{gatewayAPIDualstackAnnotationKey: gatewayAPIDualstackAnnotationValue},
setsLabel: true,
},
{
desc: "correct-annotation-key-incorrect-value",
in: map[string]string{GatewayAPIDualstackAnnotationKey: "foo"},
in: map[string]string{gatewayAPIDualstackAnnotationKey: "foo"},
setsLabel: false,
},
{
desc: "incorrect-annotation-key-correct-value",
in: map[string]string{"FOO": GatewayAPIDualstackAnnotationValue},
in: map[string]string{"FOO": gatewayAPIDualstackAnnotationValue},
setsLabel: false,
},
}