@@ -7,16 +7,18 @@ import (
7
7
)
8
8
9
9
const (
10
- // IndexFieldKongPluginBindingKongPluginReference is the index field for KongPlugin -> KongPluginBinding.
11
- IndexFieldKongPluginBindingKongPluginReference = "kongPluginRef"
12
- // IndexFieldKongPluginBindingKongServiceReference is the index field for KongService -> KongPluginBinding.
13
- IndexFieldKongPluginBindingKongServiceReference = "kongServiceRef"
14
- // IndexFieldKongPluginBindingKongRouteReference is the index field for KongRoute -> KongPluginBinding.
15
- IndexFieldKongPluginBindingKongRouteReference = "kongRouteRef"
16
- // IndexFieldKongPluginBindingKongConsumerReference is the index field for KongConsumer -> KongPluginBinding.
17
- IndexFieldKongPluginBindingKongConsumerReference = "kongConsumerRef"
18
- // IndexFieldKongPluginBindingKongConsumerGroupReference is the index field for KongConsumerGroup -> KongPluginBinding.
19
- IndexFieldKongPluginBindingKongConsumerGroupReference = "kongConsumerGroupRef"
10
+ // IndexFieldKongPluginBindingKongPluginReference is the index field for KongPluginBinding -> KongPlugin.
11
+ IndexFieldKongPluginBindingKongPluginReference = "kongPluginBindingPluginRef"
12
+ // IndexFieldKongPluginBindingKongServiceReference is the index field for KongPluginBinding -> KongService.
13
+ IndexFieldKongPluginBindingKongServiceReference = "kongPluginBindingServiceRef"
14
+ // IndexFieldKongPluginBindingKongRouteReference is the index field for KongPluginBinding -> KongRoute.
15
+ IndexFieldKongPluginBindingKongRouteReference = "kongPluginBindingRouteRef"
16
+ // IndexFieldKongPluginBindingKongConsumerReference is the index field for KongPluginBinding -> KongConsumer.
17
+ IndexFieldKongPluginBindingKongConsumerReference = "kongPluginBindingConsumerRef"
18
+ // IndexFieldKongPluginBindingKongConsumerGroupReference is the index field for KongPluginBinding -> KongConsumerGroup.
19
+ IndexFieldKongPluginBindingKongConsumerGroupReference = "kongPluginBindingConsumerGroupRef"
20
+ // IndexFieldKongPluginBindingKonnectGatewayControlPlane is the index field for KongPluginBinding -> KonnectGatewayControlPlane.
21
+ IndexFieldKongPluginBindingKonnectGatewayControlPlane = "kongPluginBindingKonnectGatewayControlPlaneRef"
20
22
)
21
23
22
24
// IndexOptionsForKongPluginBinding returns required Index options for KongPluginBinding reconclier.
@@ -47,6 +49,11 @@ func IndexOptionsForKongPluginBinding() []ReconciliationIndexOption {
47
49
IndexField : IndexFieldKongPluginBindingKongConsumerGroupReference ,
48
50
ExtractValue : kongConsumerGroupReferencesFromKongPluginBinding ,
49
51
},
52
+ {
53
+ IndexObject : & configurationv1alpha1.KongPluginBinding {},
54
+ IndexField : IndexFieldKongPluginBindingKonnectGatewayControlPlane ,
55
+ ExtractValue : kongPluginBindingReferencesKonnectGatewayControlPlane ,
56
+ },
50
57
}
51
58
}
52
59
@@ -113,3 +120,27 @@ func kongConsumerGroupReferencesFromKongPluginBinding(obj client.Object) []strin
113
120
}
114
121
return []string {binding .Spec .Targets .ConsumerGroupReference .Name }
115
122
}
123
+
124
+ // kongPluginBindingReferencesKonnectGatewayControlPlane returns name of referenced KonnectGatewayControlPlane in KongPluginBinding spec.
125
+ func kongPluginBindingReferencesKonnectGatewayControlPlane (obj client.Object ) []string {
126
+ binding , ok := obj .(* configurationv1alpha1.KongPluginBinding )
127
+ if ! ok {
128
+ return nil
129
+ }
130
+ cpRef := binding .Spec .ControlPlaneRef
131
+ if cpRef == nil ||
132
+ cpRef .Type != configurationv1alpha1 .ControlPlaneRefKonnectNamespacedRef ||
133
+ cpRef .KonnectNamespacedRef == nil {
134
+ return nil
135
+ }
136
+
137
+ // NOTE: This provides support for setting the namespace of the KonnectGatewayControlPlane ref
138
+ // but CRDs have validation rules in place which will disallow this until
139
+ // cross namespace refs are allowed.
140
+ namespace := binding .Namespace
141
+ if cpRef .KonnectNamespacedRef .Namespace != "" {
142
+ namespace = cpRef .KonnectNamespacedRef .Namespace
143
+ }
144
+
145
+ return []string {namespace + "/" + cpRef .KonnectNamespacedRef .Name }
146
+ }
0 commit comments