Skip to content

Commit a7a896a

Browse files
committed
feat(lb): use bool ptr for ssl bridging annotations
1 parent 4c60937 commit a7a896a

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

scaleway/loadbalancers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,8 @@ func servicePortToBackend(service *v1.Service, loadbalancer *scwlb.LB, port v1.S
11181118
Name: fmt.Sprintf("%s_tcp_%d", string(service.UID), port.NodePort),
11191119
Pool: nodeIPs,
11201120
ForwardProtocol: protocol,
1121-
SslBridging: scw.BoolPtr(sslBridging),
1122-
IgnoreSslServerVerify: scw.BoolPtr(sslSkipVerify),
1121+
SslBridging: sslBridging,
1122+
IgnoreSslServerVerify: sslSkipVerify,
11231123
ForwardPort: port.NodePort,
11241124
ForwardPortAlgorithm: forwardPortAlgorithm,
11251125
StickySessions: stickySessions,

scaleway/loadbalancers_annotations.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,11 @@ func getForwardProtocol(service *v1.Service, nodePort int32) (scwlb.Protocol, er
553553
return scwlb.ProtocolTCP, nil
554554
}
555555

556-
func getSSLBridging(service *v1.Service, nodePort int32) (bool, error) {
557-
tlsEnabled := service.Annotations[serviceAnnotationLoadBalancerHTTPBackendTLS]
556+
func getSSLBridging(service *v1.Service, nodePort int32) (*bool, error) {
557+
tlsEnabled, found := service.Annotations[serviceAnnotationLoadBalancerHTTPBackendTLS]
558+
if !found {
559+
return nil, nil
560+
}
558561

559562
var svcPort int32 = -1
560563
for _, p := range service.Spec.Ports {
@@ -564,20 +567,23 @@ func getSSLBridging(service *v1.Service, nodePort int32) (bool, error) {
564567
}
565568
if svcPort == -1 {
566569
klog.Errorf("no valid port found")
567-
return false, errLoadBalancerInvalidAnnotation
570+
return nil, errLoadBalancerInvalidAnnotation
568571
}
569572

570573
isTLSEnabled, err := isPortInRange(tlsEnabled, svcPort)
571574
if err != nil {
572575
klog.Errorf("unable to check if port %d is in range %s", svcPort, tlsEnabled)
573-
return false, err
576+
return nil, err
574577
}
575578

576-
return isTLSEnabled, nil
579+
return scw.BoolPtr(isTLSEnabled), nil
577580
}
578581

579-
func getSSLBridgingSkipVerify(service *v1.Service, nodePort int32) (bool, error) {
580-
skipTLSVerify := service.Annotations[serviceAnnotationLoadBalancerHTTPBackendTLSSkipVerify]
582+
func getSSLBridgingSkipVerify(service *v1.Service, nodePort int32) (*bool, error) {
583+
skipTLSVerify, found := service.Annotations[serviceAnnotationLoadBalancerHTTPBackendTLSSkipVerify]
584+
if !found {
585+
return nil, nil
586+
}
581587

582588
var svcPort int32 = -1
583589
for _, p := range service.Spec.Ports {
@@ -587,16 +593,16 @@ func getSSLBridgingSkipVerify(service *v1.Service, nodePort int32) (bool, error)
587593
}
588594
if svcPort == -1 {
589595
klog.Errorf("no valid port found")
590-
return false, errLoadBalancerInvalidAnnotation
596+
return nil, errLoadBalancerInvalidAnnotation
591597
}
592598

593599
isSkipTLSVerify, err := isPortInRange(skipTLSVerify, svcPort)
594600
if err != nil {
595601
klog.Errorf("unable to check if port %d is in range %s", svcPort, skipTLSVerify)
596-
return false, err
602+
return nil, err
597603
}
598604

599-
return isSkipTLSVerify, nil
605+
return scw.BoolPtr(isSkipTLSVerify), nil
600606
}
601607

602608
func getCertificateIDs(service *v1.Service, port int32) ([]string, error) {

0 commit comments

Comments
 (0)