Skip to content

Commit 9b28dad

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent e56c05a commit 9b28dad

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

internal/provider/api7ee/provider.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
111111
case *gatewayv1alpha2.UDPRoute:
112112
result, err = d.translator.TranslateUDPRoute(tctx, t.DeepCopy())
113113
resourceTypes = append(resourceTypes, adctypes.TypeService)
114+
case *gatewayv1alpha2.TLSRoute:
115+
result, err = d.translator.TranslateTLSRoute(tctx, t.DeepCopy())
116+
resourceTypes = append(resourceTypes, adctypes.TypeService)
114117
case *gatewayv1.GRPCRoute:
115118
result, err = d.translator.TranslateGRPCRoute(tctx, t.DeepCopy())
116119
resourceTypes = append(resourceTypes, "service")
@@ -192,7 +195,7 @@ func (d *api7eeProvider) Delete(ctx context.Context, obj client.Object) error {
192195
var resourceTypes []string
193196
var labels map[string]string
194197
switch obj.(type) {
195-
case *gatewayv1.HTTPRoute, *apiv2.ApisixRoute, *gatewayv1.GRPCRoute, *gatewayv1alpha2.TCPRoute, *gatewayv1alpha2.UDPRoute:
198+
case *gatewayv1.HTTPRoute, *apiv2.ApisixRoute, *gatewayv1.GRPCRoute, *gatewayv1alpha2.TCPRoute, *gatewayv1alpha2.UDPRoute, *gatewayv1alpha2.TLSRoute:
196199
resourceTypes = append(resourceTypes, "service")
197200
labels = label.GenLabel(obj)
198201
case *gatewayv1.Gateway:

internal/provider/api7ee/status.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,41 @@ func (d *api7eeProvider) updateStatus(nnk types.NamespacedNameKind, condition me
248248
return cp
249249
}),
250250
})
251+
case types.KindTLSRoute:
252+
parentRefs := d.client.ConfigManager.GetConfigRefsByResourceKey(nnk)
253+
d.log.V(1).Info("updating TLSRoute status", "parentRefs", parentRefs)
254+
gatewayRefs := map[types.NamespacedNameKind]struct{}{}
255+
for _, parentRef := range parentRefs {
256+
if parentRef.Kind == types.KindGateway {
257+
gatewayRefs[parentRef] = struct{}{}
258+
}
259+
}
260+
d.updater.Update(status.Update{
261+
NamespacedName: nnk.NamespacedName(),
262+
Resource: &gatewayv1alpha2.TLSRoute{},
263+
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
264+
cp := obj.(*gatewayv1alpha2.TLSRoute).DeepCopy()
265+
gatewayNs := cp.GetNamespace()
266+
for i, ref := range cp.Status.Parents {
267+
ns := gatewayNs
268+
if ref.ParentRef.Namespace != nil {
269+
ns = string(*ref.ParentRef.Namespace)
270+
}
271+
if ref.ParentRef.Kind == nil || *ref.ParentRef.Kind == types.KindGateway {
272+
nnk := types.NamespacedNameKind{
273+
Name: string(ref.ParentRef.Name),
274+
Namespace: ns,
275+
Kind: types.KindGateway,
276+
}
277+
if _, ok := gatewayRefs[nnk]; ok {
278+
ref.Conditions = cutils.MergeCondition(ref.Conditions, condition)
279+
cp.Status.Parents[i] = ref
280+
}
281+
}
282+
}
283+
return cp
284+
}),
285+
})
251286
}
252287
}
253288

internal/provider/apisix/status.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,41 @@ func (d *apisixProvider) updateStatus(nnk types.NamespacedNameKind, condition me
249249
return cp
250250
}),
251251
})
252+
case types.KindTLSRoute:
253+
parentRefs := d.client.ConfigManager.GetConfigRefsByResourceKey(nnk)
254+
d.log.V(1).Info("updating TLSRoute status", "parentRefs", parentRefs)
255+
gatewayRefs := map[types.NamespacedNameKind]struct{}{}
256+
for _, parentRef := range parentRefs {
257+
if parentRef.Kind == types.KindGateway {
258+
gatewayRefs[parentRef] = struct{}{}
259+
}
260+
}
261+
d.updater.Update(status.Update{
262+
NamespacedName: nnk.NamespacedName(),
263+
Resource: &gatewayv1alpha2.TLSRoute{},
264+
Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
265+
cp := obj.(*gatewayv1alpha2.TLSRoute).DeepCopy()
266+
gatewayNs := cp.GetNamespace()
267+
for i, ref := range cp.Status.Parents {
268+
ns := gatewayNs
269+
if ref.ParentRef.Namespace != nil {
270+
ns = string(*ref.ParentRef.Namespace)
271+
}
272+
if ref.ParentRef.Kind == nil || *ref.ParentRef.Kind == types.KindGateway {
273+
nnk := types.NamespacedNameKind{
274+
Name: string(ref.ParentRef.Name),
275+
Namespace: ns,
276+
Kind: types.KindGateway,
277+
}
278+
if _, ok := gatewayRefs[nnk]; ok {
279+
ref.Conditions = cutils.MergeCondition(ref.Conditions, condition)
280+
cp.Status.Parents[i] = ref
281+
}
282+
}
283+
}
284+
return cp
285+
}),
286+
})
252287
}
253288
}
254289

test/e2e/framework/manifests/dp.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ spec:
213213
name: admin
214214
protocol: TCP
215215
- containerPort: 9443
216-
name: tls
216+
name: https
217217
protocol: TCP
218218
- containerPort: 9090
219219
name: control-api

0 commit comments

Comments
 (0)