Skip to content

Commit 69c8693

Browse files
committed
chore: add indexer for listing gateways by classname
1 parent 100bbc8 commit 69c8693

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

internal/controller/indexer/indexer.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
IngressClassParametersRef = "ingressClassParametersRef"
2525
ConsumerGatewayRef = "consumerGatewayRef"
2626
PolicyTargetRefs = "targetRefs"
27+
GatewayClassIndexRef = "gatewayClassRef"
2728
)
2829

2930
func SetupIndexer(mgr ctrl.Manager) error {
@@ -191,6 +192,17 @@ func setupGatewayProxyIndexer(mgr ctrl.Manager) error {
191192
return nil
192193
}
193194

195+
func setupGatewayClassIndexer(mgr ctrl.Manager) error {
196+
return mgr.GetFieldIndexer().IndexField(
197+
context.Background(),
198+
&gatewayv1.Gateway{},
199+
GatewayClassIndexRef,
200+
func(obj client.Object) (requests []string) {
201+
return []string{string(obj.(*gatewayv1.Gateway).Spec.GatewayClassName)}
202+
},
203+
)
204+
}
205+
194206
func GatewayProxySecretIndexFunc(rawObj client.Object) []string {
195207
gatewayProxy := rawObj.(*v1alpha1.GatewayProxy)
196208
secretKeys := make([]string, 0)

0 commit comments

Comments
 (0)