-
Notifications
You must be signed in to change notification settings - Fork 474
/
gateway_checker.go
50 lines (39 loc) · 1.38 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
package checkers
import (
networking_v1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1"
"github.com/kiali/kiali/business/checkers/gateways"
"github.com/kiali/kiali/models"
)
const GatewayCheckerType = "gateway"
type GatewayChecker struct {
Gateways []*networking_v1beta1.Gateway
WorkloadsPerNamespace map[string]models.WorkloadList
IsGatewayToNamespace bool
}
// 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{
Gateways: g.Gateways,
}.Check()
for _, gw := range g.Gateways {
validations.MergeValidations(g.runSingleChecks(gw))
}
return validations
}
func (g GatewayChecker) runSingleChecks(gw *networking_v1beta1.Gateway) models.IstioValidations {
key, validations := EmptyValidValidation(gw.Name, gw.Namespace, GatewayCheckerType)
enabledCheckers := []Checker{
gateways.SelectorChecker{
Gateway: gw,
WorkloadsPerNamespace: g.WorkloadsPerNamespace,
IsGatewayToNamespace: g.IsGatewayToNamespace,
},
}
for _, checker := range enabledCheckers {
checks, validChecker := checker.Check()
validations.Checks = append(validations.Checks, checks...)
validations.Valid = validations.Valid && validChecker
}
return models.IstioValidations{key: validations}
}