@@ -28,7 +28,7 @@ import (
28
28
"k8s.io/apimachinery/pkg/runtime"
29
29
"k8s.io/apimachinery/pkg/types"
30
30
clientgotesting "k8s.io/client-go/testing"
31
- "k8s.io/utils/pointer "
31
+ "k8s.io/utils/ptr "
32
32
33
33
fakegwapiclientset "knative.dev/net-gateway-api/pkg/client/injection/client/fake"
34
34
"knative.dev/net-gateway-api/pkg/reconciler/ingress/config"
@@ -46,8 +46,8 @@ import (
46
46
47
47
gatewayapi "sigs.k8s.io/gateway-api/apis/v1beta1"
48
48
49
- . "knative.dev/net-gateway-api/pkg/reconciler/testing"
50
- . "knative.dev/pkg/reconciler/testing"
49
+ gwtesting "knative.dev/net-gateway-api/pkg/reconciler/testing"
50
+ ktesting "knative.dev/pkg/reconciler/testing"
51
51
)
52
52
53
53
var (
57
57
privateSvc = network .GetServiceHostname (privateName , testNamespace )
58
58
59
59
gatewayRef = gatewayapi.ParentReference {
60
- Group : (* gatewayapi .Group )(pointer . String ("gateway.networking.k8s.io" )),
61
- Kind : (* gatewayapi .Kind )(pointer . String ("Gateway" )),
62
- Namespace : (* gatewayapi .Namespace )(pointer . String ("istio-system" )),
60
+ Group : (* gatewayapi .Group )(ptr . To ("gateway.networking.k8s.io" )),
61
+ Kind : (* gatewayapi .Kind )(ptr . To ("Gateway" )),
62
+ Namespace : (* gatewayapi .Namespace )(ptr . To ("istio-system" )),
63
63
Name : gatewayapi .ObjectName ("istio-gateway" ),
64
64
}
65
65
)
@@ -137,7 +137,7 @@ var (
137
137
138
138
// TODO: Add more tests - e.g. invalid ingress, delete ingress, etc.
139
139
func TestReconcile (t * testing.T ) {
140
- table := TableTest {{
140
+ table := ktesting. TableTest {{
141
141
Name : "bad workqueue key" ,
142
142
Key : "too/many/parts" ,
143
143
}, {
@@ -187,8 +187,8 @@ func TestReconcile(t *testing.T) {
187
187
Patch : []byte (`{"metadata":{"finalizers":["ingresses.networking.internal.knative.dev"],"resourceVersion":""}}` ),
188
188
}},
189
189
WantEvents : []string {
190
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
191
- Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
190
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
191
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
192
192
},
193
193
}, {
194
194
Name : "reconcile ready ingress" ,
@@ -200,7 +200,7 @@ func TestReconcile(t *testing.T) {
200
200
// no extra update
201
201
}}
202
202
203
- table .Test (t , MakeFactory (func (ctx context.Context , listers * Listers , cmw configmap.Watcher ) controller.Reconciler {
203
+ table .Test (t , gwtesting . MakeFactory (func (ctx context.Context , listers * gwtesting. Listers , _ configmap.Watcher ) controller.Reconciler {
204
204
r := & Reconciler {
205
205
gwapiclient : fakegwapiclientset .Get (ctx ),
206
206
// Listers index properties about resources
@@ -225,7 +225,7 @@ func TestReconcile(t *testing.T) {
225
225
}
226
226
227
227
func TestReconcileProberNotReady (t * testing.T ) {
228
- table := TableTest {{
228
+ table := ktesting. TableTest {{
229
229
Name : "first reconcile basic ingress wth prober" ,
230
230
Key : "ns/name" ,
231
231
Objects : append ([]runtime.Object {
@@ -246,12 +246,12 @@ func TestReconcileProberNotReady(t *testing.T) {
246
246
Patch : []byte (`{"metadata":{"finalizers":["ingresses.networking.internal.knative.dev"],"resourceVersion":""}}` ),
247
247
}},
248
248
WantEvents : []string {
249
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
250
- Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
249
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
250
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
251
251
},
252
252
}}
253
253
254
- table .Test (t , MakeFactory (func (ctx context.Context , listers * Listers , cmw configmap.Watcher ) controller.Reconciler {
254
+ table .Test (t , gwtesting . MakeFactory (func (ctx context.Context , listers * gwtesting. Listers , _ configmap.Watcher ) controller.Reconciler {
255
255
r := & Reconciler {
256
256
gwapiclient : fakegwapiclientset .Get (ctx ),
257
257
// Listers index properties about resources
@@ -277,7 +277,7 @@ func TestReconcileTLS(t *testing.T) {
277
277
secretName := "name-WE-STICK-A-LONG-UID-HERE"
278
278
nsName := "ns"
279
279
deleteTime := time .Now ().Add (- 10 * time .Second )
280
- table := TableTest {{
280
+ table := ktesting. TableTest {{
281
281
Name : "Happy TLS" ,
282
282
Key : "ns/name" ,
283
283
Objects : []runtime.Object {
@@ -312,8 +312,8 @@ func TestReconcileTLS(t *testing.T) {
312
312
}),
313
313
}},
314
314
WantEvents : []string {
315
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
316
- Eventf (corev1 .EventTypeNormal , "Created" , `Created HTTPRoute "example.com"` ),
315
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
316
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , `Created HTTPRoute "example.com"` ),
317
317
},
318
318
}, {
319
319
Name : "Already Configured" ,
@@ -390,10 +390,10 @@ func TestReconcileTLS(t *testing.T) {
390
390
}),
391
391
}},
392
392
WantEvents : []string {
393
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
394
- Eventf (corev1 .EventTypeNormal , "Created" , `Created HTTPRoute "example.com"` ),
395
- Eventf (corev1 .EventTypeWarning , "GatewayMissing" , `Unable to update Gateway istio-system/istio-gateway` ),
396
- Eventf (corev1 .EventTypeWarning , "InternalError" , `Gateway istio-system/istio-gateway does not exist: gateway.gateway.networking.k8s.io "istio-gateway" not found` ),
393
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
394
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , `Created HTTPRoute "example.com"` ),
395
+ ktesting . Eventf (corev1 .EventTypeWarning , "GatewayMissing" , `Unable to update Gateway istio-system/istio-gateway` ),
396
+ ktesting . Eventf (corev1 .EventTypeWarning , "InternalError" , `Gateway istio-system/istio-gateway does not exist: gateway.gateway.networking.k8s.io "istio-gateway" not found` ),
397
397
},
398
398
}, {
399
399
Name : "TLS ingress with httpOption redirected" ,
@@ -432,13 +432,13 @@ func TestReconcileTLS(t *testing.T) {
432
432
Patch : []byte (`{"metadata":{"finalizers":["ingresses.networking.internal.knative.dev"],"resourceVersion":""}}` ),
433
433
}},
434
434
WantEvents : []string {
435
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
436
- Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
437
- Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com-redirect\" " ),
435
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
436
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
437
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com-redirect\" " ),
438
438
},
439
439
}}
440
440
441
- table .Test (t , GatewayFactory (func (ctx context.Context , listers * Listers , cmw configmap.Watcher , tr * TableRow ) controller.Reconciler {
441
+ table .Test (t , GatewayFactory (func (ctx context.Context , listers * gwtesting. Listers , _ configmap.Watcher , tr * ktesting. TableRow ) controller.Reconciler {
442
442
r := & Reconciler {
443
443
gwapiclient : fakegwapiclientset .Get (ctx ),
444
444
httprouteLister : listers .GetHTTPRouteLister (),
@@ -475,7 +475,7 @@ func TestReconcileTLS(t *testing.T) {
475
475
func TestReconcileProbeError (t * testing.T ) {
476
476
theError := errors .New ("this is the error" )
477
477
478
- table := TableTest {{
478
+ table := ktesting. TableTest {{
479
479
Name : "first reconcile basic ingress" ,
480
480
Key : "ns/name" ,
481
481
WantErr : true ,
@@ -497,13 +497,13 @@ func TestReconcileProbeError(t *testing.T) {
497
497
Patch : []byte (`{"metadata":{"finalizers":["ingresses.networking.internal.knative.dev"],"resourceVersion":""}}` ),
498
498
}},
499
499
WantEvents : []string {
500
- Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
501
- Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
502
- Eventf (corev1 .EventTypeWarning , "InternalError" , fmt .Sprintf ("failed to probe Ingress: %v" , theError )),
500
+ ktesting . Eventf (corev1 .EventTypeNormal , "FinalizerUpdate" , `Updated "name" finalizers` ),
501
+ ktesting . Eventf (corev1 .EventTypeNormal , "Created" , "Created HTTPRoute \" example.com\" " ),
502
+ ktesting . Eventf (corev1 .EventTypeWarning , "InternalError" , fmt .Sprintf ("failed to probe Ingress: %v" , theError )),
503
503
},
504
504
}}
505
505
506
- table .Test (t , MakeFactory (func (ctx context.Context , listers * Listers , cmw configmap.Watcher ) controller.Reconciler {
506
+ table .Test (t , gwtesting . MakeFactory (func (ctx context.Context , listers * gwtesting. Listers , _ configmap.Watcher ) controller.Reconciler {
507
507
r := & Reconciler {
508
508
gwapiclient : fakegwapiclientset .Get (ctx ),
509
509
// Listers index properties about resources
@@ -562,7 +562,7 @@ type HTTPRouteOption func(h *gatewayapi.HTTPRoute)
562
562
563
563
func withSectionName (sectionName string ) HTTPRouteOption {
564
564
return func (h * gatewayapi.HTTPRoute ) {
565
- h .Spec .CommonRouteSpec .ParentRefs [0 ].SectionName = (* gatewayapi .SectionName )(pointer . String (sectionName ))
565
+ h .Spec .CommonRouteSpec .ParentRefs [0 ].SectionName = (* gatewayapi .SectionName )(ptr . To (sectionName ))
566
566
}
567
567
}
568
568
@@ -589,14 +589,14 @@ func (t *testConfigStore) ToContext(ctx context.Context) context.Context {
589
589
}
590
590
591
591
// We need to inject the row's `Objects` to work-around improper pluralization in UnsafeGuessKindToResource
592
- func GatewayFactory (ctor func (context.Context , * Listers , configmap.Watcher , * TableRow ) controller.Reconciler ) Factory {
593
- return func (t * testing.T , r * TableRow ) (
594
- controller.Reconciler , ActionRecorderList , EventList ,
592
+ func GatewayFactory (ctor func (context.Context , * gwtesting. Listers , configmap.Watcher , * ktesting. TableRow ) controller.Reconciler ) ktesting. Factory {
593
+ return func (t * testing.T , r * ktesting. TableRow ) (
594
+ controller.Reconciler , ktesting. ActionRecorderList , ktesting. EventList ,
595
595
) {
596
- shim := func (c context.Context , l * Listers , cw configmap.Watcher ) controller.Reconciler {
596
+ shim := func (c context.Context , l * gwtesting. Listers , cw configmap.Watcher ) controller.Reconciler {
597
597
return ctor (c , l , cw , r )
598
598
}
599
- return MakeFactory (shim )(t , r )
599
+ return gwtesting . MakeFactory (shim )(t , r )
600
600
}
601
601
}
602
602
@@ -634,18 +634,18 @@ func tlsListener(hostname, nsName, secretName string) GatewayOption {
634
634
Port : 443 ,
635
635
Protocol : "HTTPS" ,
636
636
TLS : & gatewayapi.GatewayTLSConfig {
637
- Mode : (* gatewayapi .TLSModeType )(pointer . String ("Terminate" )),
637
+ Mode : (* gatewayapi .TLSModeType )(ptr . To ("Terminate" )),
638
638
CertificateRefs : []gatewayapi.SecretObjectReference {{
639
- Group : (* gatewayapi .Group )(pointer . String ("" )),
640
- Kind : (* gatewayapi .Kind )(pointer . String ("Secret" )),
639
+ Group : (* gatewayapi .Group )(ptr . To ("" )),
640
+ Kind : (* gatewayapi .Kind )(ptr . To ("Secret" )),
641
641
Name : gatewayapi .ObjectName (secretName ),
642
642
Namespace : (* gatewayapi .Namespace )(& nsName ),
643
643
}},
644
644
Options : map [gatewayapi.AnnotationKey ]gatewayapi.AnnotationValue {},
645
645
},
646
646
AllowedRoutes : & gatewayapi.AllowedRoutes {
647
647
Namespaces : & gatewayapi.RouteNamespaces {
648
- From : (* gatewayapi .FromNamespaces )(pointer . String ("Selector" )),
648
+ From : (* gatewayapi .FromNamespaces )(ptr . To ("Selector" )),
649
649
Selector : & metav1.LabelSelector {
650
650
MatchLabels : map [string ]string {
651
651
"kubernetes.io/metadata.name" : nsName ,
0 commit comments