openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)

Home Page:https://openyurt.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[feature request]extract list object handling from ObjectFilter to ResponseFilter

rambohe-ch opened this issue · comments

What would you like to be added:
In each ObjectFilter(like masterservice, servicetopology, etc.), filter need to handle standalone object and List object. For example, masterservice filter need to handle *v1.ServiceList and *v1.Service as following:

func (msf *masterServiceFilter) Filter(obj runtime.Object, _ <-chan struct{}) runtime.Object {
switch v := obj.(type) {
case *v1.ServiceList:
for i := range v.Items {
mutated := msf.mutateMasterService(&v.Items[i])
if mutated {
// short-circuit break
break
}
}
return v
case *v1.Service:
msf.mutateMasterService(v)
return v

And handling list object is just a collection of standalone object handling, so it is a good idea to handle list object in a common place like ResponseFilter instead of handling them in every ObjectFilter.

So i will make a pull request to improve list object handling in ObjectFilter, then ObjectFilter only need to handle standalone object(like *v1.Service).

others
/kind feature