MCPcopy
hub / github.com/kubernetes/client-go / OnUpdate

Method OnUpdate

tools/cache/controller.go:231–244  ·  view source on GitHub ↗

OnUpdate ensures the proper handler is called depending on whether the filter matches

(oldObj, newObj interface{})

Source from the content-addressed store, hash-verified

229
230// OnUpdate ensures the proper handler is called depending on whether the filter matches
231func (r FilteringResourceEventHandler) OnUpdate(oldObj, newObj interface{}) {
232 newer := r.FilterFunc(newObj)
233 older := r.FilterFunc(oldObj)
234 switch {
235 case newer && older:
236 r.Handler.OnUpdate(oldObj, newObj)
237 case newer && !older:
238 r.Handler.OnAdd(newObj)
239 case !newer && older:
240 r.Handler.OnDelete(oldObj)
241 default:
242 // do nothing
243 }
244}
245
246// OnDelete calls the nested handler only if the filter succeeds
247func (r FilteringResourceEventHandler) OnDelete(obj interface{}) {

Callers

nothing calls this directly

Calls 3

OnUpdateMethod · 0.65
OnAddMethod · 0.65
OnDeleteMethod · 0.65

Tested by

no test coverage detected