Skip to content

Commit 33bfc1a

Browse files
committed
lint
1 parent 82d8cd4 commit 33bfc1a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

internal/adc/translator/apisixroute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func (t *Translator) translateApisixRouteHTTPBackend(tctx *provider.TranslateCon
369369
}
370370
upstream.Nodes = nodes
371371
upstream.Scheme = appProtocolToUpstreamScheme(protocol)
372-
if protocol == "kubernetes.io/ws" || protocol == "kubernetes.io/wss" {
372+
if protocol == internaltypes.AppProtocolWS || protocol == internaltypes.AppProtocolWSS {
373373
*enableWebsocket = ptr.To(true)
374374
}
375375
if backend.Weight != nil {

internal/adc/translator/httproute.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ func (t *Translator) TranslateHTTPRoute(tctx *provider.TranslateContext, httpRou
565565
if len(upNodes) == 0 {
566566
continue
567567
}
568-
if protocol == "kubernetes.io/ws" || protocol == "kubernetes.io/wss" {
568+
if protocol == internaltypes.AppProtocolWS || protocol == internaltypes.AppProtocolWSS {
569569
enableWebsocket = ptr.To(true)
570570
}
571571

@@ -836,11 +836,13 @@ func (t *Translator) translateHTTPRouteHeaderMatchToVars(header gatewayv1.HTTPHe
836836

837837
func appProtocolToUpstreamScheme(appProtocol string) string {
838838
switch appProtocol {
839-
case "http":
839+
case internaltypes.AppProtocolHTTP:
840840
return apiv2.SchemeHTTP
841-
case "https":
841+
case internaltypes.AppProtocolHTTPS:
842842
return apiv2.SchemeHTTPS
843-
case "kubernetes.io/wss":
843+
case internaltypes.AppProtocolWS:
844+
return apiv2.SchemeHTTP
845+
case internaltypes.AppProtocolWSS:
844846
return apiv2.SchemeHTTPS
845847
default:
846848
return ""

internal/types/k8s.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ const (
5757
KindApisixUpstream = "ApisixUpstream"
5858
)
5959

60+
const (
61+
AppProtocolHTTP = "http"
62+
AppProtocolHTTPS = "https"
63+
AppProtocolWS = "kubernetes.io/ws"
64+
AppProtocolWSS = "kubernetes.io/wss"
65+
)
66+
6067
func KindOf(obj any) string {
6168
switch obj.(type) {
6269
case *gatewayv1.Gateway:

0 commit comments

Comments
 (0)