in pkg/k8scontext/context.go [360:389]
func (c *Context) ListServices() []*v1.Service {
var serviceList []*v1.Service
if IsInMultiClusterMode {
for _, multiClusterServiceInterface := range c.Caches.MultiClusterService.List() {
multiClusterService := multiClusterServiceInterface.(*multiClusterService.MultiClusterService)
service, exists := convert.FromMultiClusterService(multiClusterService)
if !exists {
klog.Error("Unable to convert MultiClusterService to Service")
continue
}
if _, exists := c.namespaces[service.Namespace]; len(c.namespaces) > 0 && !exists {
continue
}
if hasTCPPort(service) {
serviceList = append(serviceList, service)
}
}
} else {
for _, serviceInterface := range c.Caches.Service.List() {
service := serviceInterface.(*v1.Service)
if _, exists := c.namespaces[service.Namespace]; len(c.namespaces) > 0 && !exists {
continue
}
if hasTCPPort(service) {
serviceList = append(serviceList, service)
}
}
}
return serviceList
}