@@ -69,6 +69,9 @@ func (r LoggingResourceRepository) LoggingResourcesFor(ctx context.Context, logg
6969 res .Fluentbits , err = r .FluentbitsFor (ctx , logging )
7070 errs = errors .Append (errs , err )
7171
72+ res .LoggingRoutes , err = r .LoggingRoutesFor (ctx , logging )
73+ errs = errors .Append (errs , err )
74+
7275 res .WatchNamespaces , err = UniqueWatchNamespaces (ctx , r .Client , & logging )
7376 if err != nil {
7477 errs = errors .Append (errs , err )
@@ -145,16 +148,17 @@ func (r LoggingResourceRepository) ClusterFlowsFor(ctx context.Context, logging
145148 return nil , err
146149 }
147150
148- sort .Slice (list .Items , func (i , j int ) bool {
149- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
150- })
151-
152151 var res []v1beta1.ClusterFlow
153152 for _ , i := range list .Items {
154153 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
155154 res = append (res , i )
156155 }
157156 }
157+
158+ sort .Slice (res , func (i , j int ) bool {
159+ return lessByNamespacedName (& res [i ], & res [j ])
160+ })
161+
158162 return res , nil
159163}
160164
@@ -164,16 +168,17 @@ func (r LoggingResourceRepository) ClusterOutputsFor(ctx context.Context, loggin
164168 return nil , err
165169 }
166170
167- sort .Slice (list .Items , func (i , j int ) bool {
168- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
169- })
170-
171171 var res []v1beta1.ClusterOutput
172172 for _ , i := range list .Items {
173173 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
174174 res = append (res , i )
175175 }
176176 }
177+
178+ sort .Slice (res , func (i , j int ) bool {
179+ return lessByNamespacedName (& res [i ], & res [j ])
180+ })
181+
177182 return res , nil
178183}
179184
@@ -183,16 +188,17 @@ func (r LoggingResourceRepository) FlowsInNamespaceFor(ctx context.Context, name
183188 return nil , err
184189 }
185190
186- sort .Slice (list .Items , func (i , j int ) bool {
187- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
188- })
189-
190191 var res []v1beta1.Flow
191192 for _ , i := range list .Items {
192193 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
193194 res = append (res , i )
194195 }
195196 }
197+
198+ sort .Slice (res , func (i , j int ) bool {
199+ return lessByNamespacedName (& res [i ], & res [j ])
200+ })
201+
196202 return res , nil
197203}
198204
@@ -202,16 +208,16 @@ func (r LoggingResourceRepository) OutputsInNamespaceFor(ctx context.Context, na
202208 return nil , err
203209 }
204210
205- sort .Slice (list .Items , func (i , j int ) bool {
206- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
207- })
208-
209211 var res []v1beta1.Output
210212 for _ , i := range list .Items {
211213 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
212214 res = append (res , i )
213215 }
214216 }
217+
218+ sort .Slice (res , func (i , j int ) bool {
219+ return lessByNamespacedName (& res [i ], & res [j ])
220+ })
215221 return res , nil
216222}
217223
@@ -221,16 +227,16 @@ func (r LoggingResourceRepository) SyslogNGClusterFlowsFor(ctx context.Context,
221227 return nil , err
222228 }
223229
224- sort .Slice (list .Items , func (i , j int ) bool {
225- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
226- })
227-
228230 var res []v1beta1.SyslogNGClusterFlow
229231 for _ , i := range list .Items {
230232 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
231233 res = append (res , i )
232234 }
233235 }
236+
237+ sort .Slice (res , func (i , j int ) bool {
238+ return lessByNamespacedName (& res [i ], & res [j ])
239+ })
234240 return res , nil
235241}
236242
@@ -240,16 +246,15 @@ func (r LoggingResourceRepository) SyslogNGClusterOutputsFor(ctx context.Context
240246 return nil , err
241247 }
242248
243- sort .Slice (list .Items , func (i , j int ) bool {
244- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
245- })
246-
247249 var res []v1beta1.SyslogNGClusterOutput
248250 for _ , i := range list .Items {
249251 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
250252 res = append (res , i )
251253 }
252254 }
255+ sort .Slice (res , func (i , j int ) bool {
256+ return lessByNamespacedName (& res [i ], & res [j ])
257+ })
253258 return res , nil
254259}
255260
@@ -259,16 +264,15 @@ func (r LoggingResourceRepository) SyslogNGFlowsInNamespaceFor(ctx context.Conte
259264 return nil , err
260265 }
261266
262- sort .Slice (list .Items , func (i , j int ) bool {
263- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
264- })
265-
266267 var res []v1beta1.SyslogNGFlow
267268 for _ , i := range list .Items {
268269 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
269270 res = append (res , i )
270271 }
271272 }
273+ sort .Slice (res , func (i , j int ) bool {
274+ return lessByNamespacedName (& res [i ], & res [j ])
275+ })
272276 return res , nil
273277}
274278
@@ -278,16 +282,15 @@ func (r LoggingResourceRepository) SyslogNGOutputsInNamespaceFor(ctx context.Con
278282 return nil , err
279283 }
280284
281- sort .Slice (list .Items , func (i , j int ) bool {
282- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
283- })
284-
285285 var res []v1beta1.SyslogNGOutput
286286 for _ , i := range list .Items {
287287 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
288288 res = append (res , i )
289289 }
290290 }
291+ sort .Slice (res , func (i , j int ) bool {
292+ return lessByNamespacedName (& res [i ], & res [j ])
293+ })
291294 return res , nil
292295}
293296
@@ -302,16 +305,15 @@ func (r LoggingResourceRepository) NodeAgentsFor(ctx context.Context, logging v1
302305 return nil , err
303306 }
304307
305- sort .Slice (list .Items , func (i , j int ) bool {
306- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
307- })
308-
309308 var res []v1beta1.NodeAgent
310309 for _ , i := range list .Items {
311310 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
312311 res = append (res , i )
313312 }
314313 }
314+ sort .Slice (res , func (i , j int ) bool {
315+ return lessByNamespacedName (& res [i ], & res [j ])
316+ })
315317 return res , nil
316318}
317319
@@ -321,16 +323,33 @@ func (r LoggingResourceRepository) FluentbitsFor(ctx context.Context, logging v1
321323 return nil , err
322324 }
323325
324- sort .Slice (list .Items , func (i , j int ) bool {
325- return lessByNamespacedName (& list .Items [i ], & list .Items [j ])
326- })
327-
328326 var res []v1beta1.FluentbitAgent
329327 for _ , i := range list .Items {
330328 if i .Spec .LoggingRef == logging .Spec .LoggingRef {
331329 res = append (res , i )
332330 }
333331 }
332+ sort .Slice (res , func (i , j int ) bool {
333+ return lessByNamespacedName (& res [i ], & res [j ])
334+ })
335+ return res , nil
336+ }
337+
338+ func (r LoggingResourceRepository ) LoggingRoutesFor (ctx context.Context , logging v1beta1.Logging ) ([]v1beta1.LoggingRoute , error ) {
339+ var list v1beta1.LoggingRouteList
340+ if err := r .Client .List (ctx , & list ); err != nil {
341+ return nil , err
342+ }
343+
344+ var res []v1beta1.LoggingRoute
345+ for _ , i := range list .Items {
346+ if i .Spec .Source == logging .Spec .LoggingRef {
347+ res = append (res , i )
348+ }
349+ }
350+ sort .Slice (res , func (i , j int ) bool {
351+ return lessByNamespacedName (& res [i ], & res [j ])
352+ })
334353 return res , nil
335354}
336355
0 commit comments