Skip to content

Commit a736f4f

Browse files
committed
Remove unused functions and fix GetPointer on type int32
1 parent 8a917ee commit a736f4f

File tree

4 files changed

+15
-56
lines changed

4 files changed

+15
-56
lines changed

internal/framework/helpers/helpers.go

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/google/go-cmp/cmp"
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9-
"sigs.k8s.io/gateway-api/apis/v1beta1"
109
)
1110

1211
// Diff prints the diff between two structs.
@@ -21,46 +20,6 @@ func Diff(want, got any) string {
2120
return r
2221
}
2322

24-
// GetStringPointer takes a string and returns a pointer to it.
25-
func GetStringPointer(s string) *string {
26-
return &s
27-
}
28-
29-
// GetIntPointer takes an int and returns a pointer to it.
30-
func GetIntPointer(i int) *int {
31-
return &i
32-
}
33-
34-
// GetInt32Pointer takes an int32 and returns a pointer to it.
35-
func GetInt32Pointer(i int32) *int32 {
36-
return &i
37-
}
38-
39-
// GetHTTPMethodPointer takes an HTTPMethod and returns a pointer to it.
40-
func GetHTTPMethodPointer(m v1beta1.HTTPMethod) *v1beta1.HTTPMethod {
41-
return &m
42-
}
43-
44-
// GetHeaderMatchTypePointer takes an HeaderMatchType and returns a pointer to it.
45-
func GetHeaderMatchTypePointer(t v1beta1.HeaderMatchType) *v1beta1.HeaderMatchType {
46-
return &t
47-
}
48-
49-
// GetQueryParamMatchTypePointer takes an QueryParamMatchType and returns a pointer to it.
50-
func GetQueryParamMatchTypePointer(t v1beta1.QueryParamMatchType) *v1beta1.QueryParamMatchType {
51-
return &t
52-
}
53-
54-
// GetTLSModePointer takes a TLSModeType and returns a pointer to it.
55-
func GetTLSModePointer(t v1beta1.TLSModeType) *v1beta1.TLSModeType {
56-
return &t
57-
}
58-
59-
// GetBoolPointer takes a bool and returns a pointer to it.
60-
func GetBoolPointer(b bool) *bool {
61-
return &b
62-
}
63-
6423
// GetPointer takes a value of any type and returns a pointer to it.
6524
func GetPointer[T any](v T) *T {
6625
return &v

internal/mode/static/state/graph/graph_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestBuildGraph(t *testing.T) {
6666
Kind: (*v1beta1.Kind)(helpers.GetPointer("Service")),
6767
Name: "foo",
6868
Namespace: (*v1beta1.Namespace)(helpers.GetPointer("service")),
69-
Port: (*v1beta1.PortNumber)(helpers.GetPointer(int32(80))),
69+
Port: (*v1beta1.PortNumber)(helpers.GetPointer[int32](80)),
7070
},
7171
},
7272
},

internal/mode/static/state/relationship/relationships_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) {
2020
Kind: (*v1beta1.Kind)(helpers.GetPointer("Service")),
2121
Name: svcName,
2222
Namespace: (*v1beta1.Namespace)(helpers.GetPointer("test")),
23-
Port: (*v1beta1.PortNumber)(helpers.GetPointer(int32(80))),
23+
Port: (*v1beta1.PortNumber)(helpers.GetPointer[int32](80)),
2424
},
2525
},
2626
},
@@ -94,7 +94,7 @@ func TestGetBackendServiceNamesFromRoute(t *testing.T) {
9494
helpers.GetPointer("test"),
9595
),
9696
Port: (*v1beta1.PortNumber)(
97-
helpers.GetPointer(int32(80)),
97+
helpers.GetPointer[int32](80),
9898
),
9999
},
100100
},

internal/mode/static/state/resolver/resolver_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var (
3434
Ports: []discoveryV1.EndpointPort{
3535
{
3636
Name: &svcPortName,
37-
Port: helpers.GetPointer(int32(80)),
37+
Port: helpers.GetPointer[int32](80),
3838
},
3939
},
4040
}
@@ -54,7 +54,7 @@ var (
5454
Ports: []discoveryV1.EndpointPort{
5555
{
5656
Name: &svcPortName,
57-
Port: helpers.GetPointer(int32(80)),
57+
Port: helpers.GetPointer[int32](80),
5858
},
5959
},
6060
}
@@ -65,7 +65,7 @@ var (
6565
Ports: []discoveryV1.EndpointPort{
6666
{
6767
Name: &svcPortName,
68-
Port: helpers.GetPointer(int32(80)),
68+
Port: helpers.GetPointer[int32](80),
6969
},
7070
},
7171
}
@@ -76,7 +76,7 @@ var (
7676
Ports: []discoveryV1.EndpointPort{
7777
{
7878
Name: helpers.GetPointer("other-svc-port"),
79-
Port: helpers.GetPointer(int32(8080)),
79+
Port: helpers.GetPointer[int32](8080),
8080
},
8181
},
8282
}
@@ -387,7 +387,7 @@ func TestFindPort(t *testing.T) {
387387
ports: []discoveryV1.EndpointPort{
388388
{
389389
Name: nil,
390-
Port: helpers.GetPointer(int32(8080)),
390+
Port: helpers.GetPointer[int32](8080),
391391
},
392392
},
393393
svcPort: v1.ServicePort{
@@ -402,15 +402,15 @@ func TestFindPort(t *testing.T) {
402402
ports: []discoveryV1.EndpointPort{
403403
{
404404
Name: helpers.GetPointer("other-svc-port"),
405-
Port: helpers.GetPointer(int32(8080)),
405+
Port: helpers.GetPointer[int32](8080),
406406
},
407407
{
408408
Name: helpers.GetPointer("other-svc-port2"),
409-
Port: helpers.GetPointer(int32(8081)),
409+
Port: helpers.GetPointer[int32](8081),
410410
},
411411
{
412412
Name: helpers.GetPointer("other-svc-port3"),
413-
Port: helpers.GetPointer(int32(8082)),
413+
Port: helpers.GetPointer[int32](8082),
414414
},
415415
},
416416
svcPort: v1.ServicePort{
@@ -425,15 +425,15 @@ func TestFindPort(t *testing.T) {
425425
ports: []discoveryV1.EndpointPort{
426426
{
427427
Name: helpers.GetPointer("other-svc-port"),
428-
Port: helpers.GetPointer(int32(8080)),
428+
Port: helpers.GetPointer[int32](8080),
429429
},
430430
{
431431
Name: helpers.GetPointer("other-svc-port2"),
432-
Port: helpers.GetPointer(int32(8081)),
432+
Port: helpers.GetPointer[int32](8081),
433433
},
434434
{
435435
Name: &svcPortName, // match
436-
Port: helpers.GetPointer(int32(8082)),
436+
Port: helpers.GetPointer[int32](8082),
437437
},
438438
},
439439
svcPort: v1.ServicePort{
@@ -449,7 +449,7 @@ func TestFindPort(t *testing.T) {
449449
{
450450
// If a service port is unnamed (empty string), then the endpoint port will also be empty string.
451451
Name: helpers.GetPointer(""),
452-
Port: helpers.GetPointer(int32(8080)),
452+
Port: helpers.GetPointer[int32](8080),
453453
},
454454
},
455455
svcPort: v1.ServicePort{

0 commit comments

Comments
 (0)