Skip to content

Commit 06a1c0b

Browse files
committed
Use constants for port numbers
Signed-off-by: Kumar Atish <kumar.atish@broadcom.com>
1 parent 21528cf commit 06a1c0b

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

pkg/nsx/services/nsxserviceaccount/cluster.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ import (
3333
)
3434

3535
const (
36-
siteId = "default"
37-
enforcementpointId = "default"
38-
PortRestAPI = "rest-api"
39-
PortNSXRPCFwdProxy = "nsx-rpc-fwd-proxy"
36+
siteId = "default"
37+
enforcementpointId = "default"
38+
PortRestAPI = "rest-api"
39+
PortNumRestAPI = 10091
40+
PortNSXRPCFwdProxy = "nsx-rpc-fwd-proxy"
41+
PortNumNSXRPCFwdProxy = 10092
4042
// #nosec G101: false positive triggered by variable name which includes "secret"
4143
SecretSuffix = "-nsx-cert"
4244
SecretCAName = "ca.crt"
@@ -320,8 +322,8 @@ func (s *NSXServiceAccountService) getProxyEndpoints(ctx context.Context, obj *v
320322
return v1alpha1.NSXProxyEndpoint{
321323
Addresses: []v1alpha1.NSXProxyEndpointAddress{{IP: "127.0.0.1"}},
322324
Ports: []v1alpha1.NSXProxyEndpointPort{
323-
{Name: PortRestAPI, Port: 10091, Protocol: v1alpha1.NSXProxyProtocolTCP},
324-
{Name: PortNSXRPCFwdProxy, Port: 10092, Protocol: v1alpha1.NSXProxyProtocolTCP},
325+
{Name: PortRestAPI, Port: PortNumRestAPI, Protocol: v1alpha1.NSXProxyProtocolTCP},
326+
{Name: PortNSXRPCFwdProxy, Port: PortNumNSXRPCFwdProxy, Protocol: v1alpha1.NSXProxyProtocolTCP},
325327
},
326328
}, nil
327329
}

pkg/nsx/services/nsxserviceaccount/cluster_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,12 @@ func TestNSXServiceAccountService_CreateOrUpdateNSXServiceAccount(t *testing.T)
669669
Ports: []v1alpha1.NSXProxyEndpointPort{
670670
{
671671
Name: PortRestAPI,
672-
Port: 10091,
672+
Port: PortNumRestAPI,
673673
Protocol: v1alpha1.NSXProxyProtocolTCP,
674674
},
675675
{
676676
Name: PortNSXRPCFwdProxy,
677-
Port: 10092,
677+
Port: PortNumNSXRPCFwdProxy,
678678
Protocol: v1alpha1.NSXProxyProtocolTCP,
679679
},
680680
},
@@ -2384,12 +2384,12 @@ func TestNSXServiceAccountService_getProxyEndpoints(t *testing.T) {
23842384
Ports: []v1alpha1.NSXProxyEndpointPort{
23852385
{
23862386
Name: PortRestAPI,
2387-
Port: 10091,
2387+
Port: PortNumRestAPI,
23882388
Protocol: v1alpha1.NSXProxyProtocolTCP,
23892389
},
23902390
{
23912391
Name: PortNSXRPCFwdProxy,
2392-
Port: 10092,
2392+
Port: PortNumNSXRPCFwdProxy,
23932393
Protocol: v1alpha1.NSXProxyProtocolTCP,
23942394
},
23952395
},
@@ -2722,13 +2722,13 @@ func TestUpdateProxyEndpointsIfNeeded(t *testing.T) {
27222722
Ports: []v1alpha1.NSXProxyEndpointPort{
27232723
{
27242724
Name: PortRestAPI,
2725-
Port: 10091,
2725+
Port: PortNumRestAPI,
27262726
Protocol: v1alpha1.NSXProxyProtocolTCP,
27272727
},
27282728
{
27292729
Name: PortNSXRPCFwdProxy,
27302730
Protocol: v1alpha1.NSXProxyProtocolTCP,
2731-
Port: 10092,
2731+
Port: PortNumNSXRPCFwdProxy,
27322732
},
27332733
},
27342734
},

0 commit comments

Comments
 (0)