-
Notifications
You must be signed in to change notification settings - Fork 474
/
service_checker.go
44 lines (33 loc) · 1.16 KB
/
service_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
package checkers
import (
apps_v1 "k8s.io/api/apps/v1"
core_v1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"github.com/kiali/kiali/business/checkers/services"
"github.com/kiali/kiali/models"
)
const ServiceCheckerType = "service"
type ServiceChecker struct {
Services []v1.Service
Deployments []apps_v1.Deployment
Pods []core_v1.Pod
}
func (sc ServiceChecker) Check() models.IstioValidations {
validations := models.IstioValidations{}
for _, s := range sc.Services {
validations.MergeValidations(sc.runSingleChecks(s))
}
return validations
}
func (sc ServiceChecker) runSingleChecks(service v1.Service) models.IstioValidations {
key, validations := EmptyValidValidation(service.GetObjectMeta().GetName(), service.GetObjectMeta().GetNamespace(), ServiceCheckerType)
enabledCheckers := []Checker{
services.PortMappingChecker{Service: service, Deployments: sc.Deployments, Pods: sc.Pods},
}
for _, checker := range enabledCheckers {
checks, validChecker := checker.Check()
validations.Checks = append(validations.Checks, checks...)
validations.Valid = validations.Valid && validChecker
}
return models.IstioValidations{key: validations}
}