@@ -2,6 +2,7 @@ package kubernetes
2
2
3
3
import (
4
4
"context"
5
+ "strings"
5
6
6
7
"github.com/sirupsen/logrus"
7
8
"k8s.io/apimachinery/pkg/api/meta"
@@ -156,7 +157,7 @@ func mergeResourceEvents(cfgs map[string]SourceConfig) mergedEvents {
156
157
if _ , ok := out [resource .Type ]; ! ok {
157
158
out [resource .Type ] = make (map [config.EventType ]struct {})
158
159
}
159
- for _ , e := range flattenEventTypes (cfg .Event . Types , resource .Event . Types ) {
160
+ for _ , e := range flattenEventTypes (cfg .Event , resource .Event ) {
160
161
out [resource.Type ][e ] = struct {}{}
161
162
}
162
163
}
@@ -178,7 +179,7 @@ func (r *Router) mergeEventRoutes(resource string, cfgs map[string]SourceConfig)
178
179
cfg := srcCfg .cfg
179
180
for idx := range cfg .Resources {
180
181
r := cfg .Resources [idx ] // make sure that we work on a copy
181
- for _ , e := range flattenEventTypes (cfg .Event . Types , r .Event . Types ) {
182
+ for _ , e := range flattenEventTypes (cfg .Event , r .Event ) {
182
183
if resource != r .Type {
183
184
continue
184
185
}
@@ -188,7 +189,7 @@ func (r *Router) mergeEventRoutes(resource string, cfgs map[string]SourceConfig)
188
189
Annotations : resourceStringMap (cfg .Annotations , r .Annotations ),
189
190
Labels : resourceStringMap (cfg .Labels , r .Labels ),
190
191
ResourceName : r .Name ,
191
- Event : resourceEvent (* cfg .Event , r .Event ),
192
+ Event : resourceEvent (cfg .Event , r .Event ),
192
193
}
193
194
if e == config .UpdateEvent {
194
195
route .UpdateSetting = & config.UpdateSetting {
@@ -248,7 +249,7 @@ func (r *Router) setEventRouteForRecommendationsIfShould(routeMap *map[config.Ev
248
249
func eventRoutes (routeTable map [string ][]entry , targetResource string , targetEvent config.EventType ) []route {
249
250
var out []route
250
251
for _ , routedEvent := range routeTable [targetResource ] {
251
- if routedEvent .Event == targetEvent {
252
+ if strings . EqualFold ( string ( routedEvent .Event ), string ( targetEvent )) {
252
253
out = append (out , routedEvent .Routes ... )
253
254
}
254
255
}
@@ -287,10 +288,13 @@ func (r *Router) mappedInformer(event config.EventType) (registration, bool) {
287
288
return registration {}, false
288
289
}
289
290
290
- func flattenEventTypes (globalEvents []config.EventType , resourceEvents config.KubernetesResourceEventTypes ) []config.EventType {
291
- checkEvents := globalEvents
292
- if len (resourceEvents ) > 0 {
293
- checkEvents = resourceEvents
291
+ func flattenEventTypes (globalEvents * config.KubernetesEvent , resourceEvents config.KubernetesEvent ) []config.EventType {
292
+ var checkEvents []config.EventType
293
+ if globalEvents != nil {
294
+ checkEvents = globalEvents .Types
295
+ }
296
+ if len (resourceEvents .Types ) > 0 {
297
+ checkEvents = resourceEvents .Types
294
298
}
295
299
296
300
var out []config.EventType
@@ -321,10 +325,10 @@ func resourceStringMap(sourceMap *map[string]string, resourceMap map[string]stri
321
325
return sourceMap
322
326
}
323
327
324
- func resourceEvent (sourceEvent , resourceEvent config.KubernetesEvent ) * config.KubernetesEvent {
328
+ func resourceEvent (sourceEvent * config. KubernetesEvent , resourceEvent config.KubernetesEvent ) * config.KubernetesEvent {
325
329
if resourceEvent .AreConstraintsDefined () {
326
330
return & resourceEvent
327
331
}
328
332
329
- return & sourceEvent
333
+ return sourceEvent
330
334
}
0 commit comments