forked from kiali/kiali
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pod_checker.go
49 lines (39 loc) · 1.27 KB
/
pod_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
package checkers
import (
"github.com/kiali/kiali/services/business/checkers/pods"
"github.com/kiali/kiali/services/models"
"k8s.io/api/core/v1"
)
type PodChecker struct {
Pods []v1.Pod
}
const podsCheckerType = "pod"
// Runs all checkers for Pod objects passed into the PodChecker
func (checker PodChecker) Check() models.IstioValidations {
return checker.runIndividualChecks()
}
// Runs individual checks for each pod in pod checker.
func (checker PodChecker) runIndividualChecks() models.IstioValidations {
validations := models.IstioValidations{}
for _, pod := range checker.Pods {
validation := models.IstioValidation{
Name: pod.ObjectMeta.Name,
ObjectType: podsCheckerType,
Valid: true,
}
for _, podChecker := range checker.enabledCheckersFor(&pod) {
checks, isValid := podChecker.Check()
validation.Checks = append(validation.Checks, checks...)
validation.Valid = validation.Valid && isValid
}
key := models.IstioValidationKey{ObjectType: podsCheckerType, Name: pod.ObjectMeta.Name}
validations[key] = &validation
}
return validations
}
// Returns a list of all individual enabled checkers
func (checker *PodChecker) enabledCheckersFor(object *v1.Pod) []Checker {
return []Checker{
pods.SidecarPresenceChecker{Pod: object},
}
}