@@ -77,43 +77,44 @@ func (d *dashboardClient) Update(ctx context.Context, tctx *translator.Translate
7777
7878func (d * dashboardClient ) Delete (ctx context.Context , obj client.Object ) error {
7979 clusters := d .c .ListClusters ()
80+ kindLabel := dashboard.ListByKindLabelOptions {
81+ Kind : obj .GetObjectKind ().GroupVersionKind ().Kind ,
82+ Namespace : obj .GetNamespace (),
83+ Name : obj .GetName (),
84+ }
8085 for _ , cluster := range clusters {
81- routes , _ := cluster .Route ().List (ctx , dashboard.ListOptions {
82- From : dashboard .ListFromCache ,
83- Args : []interface {}{
84- "label" ,
85- obj .GetObjectKind ().GroupVersionKind ().Kind ,
86- obj .GetNamespace (),
87- obj .GetName (),
88- },
89- })
90-
91- for _ , route := range routes {
92- if err := cluster .Route ().Delete (ctx , route ); err != nil {
93- return err
86+ switch obj .(type ) {
87+ case * gatewayv1.Gateway :
88+ ssls , _ := cluster .SSL ().List (ctx , dashboard.ListOptions {
89+ From : dashboard .ListFromCache ,
90+ KindLabel : kindLabel ,
91+ })
92+ for _ , ssl := range ssls {
93+ if err := cluster .SSL ().Delete (ctx , ssl ); err != nil {
94+ return err
95+ }
9496 }
95- }
97+ case * gatewayv1.HTTPRoute :
98+ routes , _ := cluster .Route ().List (ctx , dashboard.ListOptions {
99+ From : dashboard .ListFromCache ,
100+ KindLabel : kindLabel ,
101+ })
96102
97- services , _ := cluster .Service ().List (ctx , dashboard.ListOptions {
98- From : dashboard .ListFromCache ,
99- Args : []interface {}{
100- "label" ,
101- obj .GetObjectKind ().GroupVersionKind ().Kind ,
102- obj .GetNamespace (),
103- obj .GetName (),
104- },
105- })
106-
107- for _ , service := range services {
108- if err := cluster .Service ().Delete (ctx , service ); err != nil {
109- return err
103+ for _ , route := range routes {
104+ if err := cluster .Route ().Delete (ctx , route ); err != nil {
105+ return err
106+ }
110107 }
111- }
112108
113- ssls , _ := cluster .SSL ().List (ctx )
114- for _ , ssl := range ssls {
115- if err := cluster .SSL ().Delete (ctx , ssl ); err != nil {
116- return err
109+ services , _ := cluster .Service ().List (ctx , dashboard.ListOptions {
110+ From : dashboard .ListFromCache ,
111+ KindLabel : kindLabel ,
112+ })
113+
114+ for _ , service := range services {
115+ if err := cluster .Service ().Delete (ctx , service ); err != nil {
116+ return err
117+ }
117118 }
118119 }
119120 }
0 commit comments