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

View File

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