-
Notifications
You must be signed in to change notification settings - Fork 7
/
ingress_class.go
47 lines (42 loc) · 1.71 KB
/
ingress_class.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package multicluster
import (
networkingv1 "github.com/flomesh-io/fsm/pkg/apis/networking/v1"
"github.com/flomesh-io/fsm/pkg/k8s/informers"
"github.com/flomesh-io/fsm/pkg/service"
)
// GetIngressControllerServices returns ingress controller services.
func (c *Client) GetIngressControllerServices() []service.MeshService {
ingressClassIfs := c.informers.List(informers.InformerKeyIngressClass)
if len(ingressClassIfs) == 0 {
return nil
}
var controllerServices []service.MeshService
for _, ingressClassIf := range ingressClassIfs {
ingressClass := ingressClassIf.(*networkingv1.IngressClass)
if len(ingressClass.Annotations) > 0 {
if ns, nsExist := ingressClass.Annotations[`meta.flomesh.io/fsm-namespace`]; nsExist && len(ns) > 0 {
if svc, svcExist := ingressClass.Annotations[`meta.flomesh.io/ingress-pipy-svc`]; svcExist && len(svc) > 0 {
controllerServices = append(controllerServices, service.MeshService{
Namespace: ns,
Name: svc,
})
}
} else if ns, nsExist = ingressClass.Annotations[`meta.flomesh.io/erie-canal-namespace`]; nsExist && len(ns) > 0 {
if svc, svcExist := ingressClass.Annotations[`meta.flomesh.io/ingress-pipy-svc`]; svcExist && len(svc) > 0 {
controllerServices = append(controllerServices, service.MeshService{
Namespace: ns,
Name: svc,
})
}
} else if ns, nsExist = ingressClass.Annotations[`meta.flomesh.io/namespace`]; nsExist && len(ns) > 0 {
if svc, svcExist := ingressClass.Annotations[`meta.flomesh.io/ingress-pipy-svc`]; svcExist && len(svc) > 0 {
controllerServices = append(controllerServices, service.MeshService{
Namespace: ns,
Name: svc,
})
}
}
}
}
return controllerServices
}