forked from kiali/kiali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gateway_checker.go
53 lines (43 loc) · 1.43 KB
/
gateway_checker.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
48
49
50
51
52
53
package checkers
import (
"github.com/kiali/kiali/business/checkers/gateways"
"github.com/kiali/kiali/kubernetes"
"github.com/kiali/kiali/models"
)
const GatewayCheckerType = "gateway"
type GatewayChecker struct {
GatewaysPerNamespace [][]kubernetes.IstioObject
Namespace string
WorkloadList models.WorkloadList
}
// Check runs checks for the all namespaces actions as well as for the single namespace validations
func (g GatewayChecker) Check() models.IstioValidations {
// Multinamespace checkers
validations := gateways.MultiMatchChecker{
GatewaysPerNamespace: g.GatewaysPerNamespace,
}.Check()
// Single namespace
for _, nssGw := range g.GatewaysPerNamespace {
for _, gw := range nssGw {
if gw.GetObjectMeta().Namespace == g.Namespace {
validations.MergeValidations(g.runSingleChecks(gw))
}
}
}
return validations
}
func (g GatewayChecker) runSingleChecks(gw kubernetes.IstioObject) models.IstioValidations {
key, validations := EmptyValidValidation(gw.GetObjectMeta().Name, gw.GetObjectMeta().Namespace, GatewayCheckerType)
enabledCheckers := []Checker{
gateways.SelectorChecker{
WorkloadList: g.WorkloadList,
Gateway: gw,
},
}
for _, checker := range enabledCheckers {
checks, validChecker := checker.Check()
validations.Checks = append(validations.Checks, checks...)
validations.Valid = validations.Valid && validChecker
}
return models.IstioValidations{key: validations}
}