forked from stackrox/kube-linter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.go
34 lines (31 loc) · 1.16 KB
/
template.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
package readinessprobe
import (
"fmt"
"github.com/slysunkin/kube-linter/lib/check"
"github.com/slysunkin/kube-linter/lib/diagnostic"
"github.com/slysunkin/kube-linter/lib/objectkinds"
"github.com/slysunkin/kube-linter/lib/templates"
"github.com/slysunkin/kube-linter/lib/templates/readinessprobe/params"
"github.com/slysunkin/kube-linter/lib/templates/util"
v1 "k8s.io/api/core/v1"
)
func init() {
templates.Register(check.Template{
HumanName: "Readiness Probe Not Specified",
Key: "readiness-probe",
Description: "Flag containers that don't specify a readiness probe",
SupportedObjectKinds: check.ObjectKindsDesc{
ObjectKinds: []string{objectkinds.DeploymentLike},
},
Parameters: params.ParamDescs,
ParseAndValidateParams: params.ParseAndValidate,
Instantiate: params.WrapInstantiateFunc(func(_ params.Params) (check.Func, error) {
return util.PerContainerCheck(func(container *v1.Container) []diagnostic.Diagnostic {
if container.ReadinessProbe == nil {
return []diagnostic.Diagnostic{{Message: fmt.Sprintf("container %q does not specify a readiness probe", container.Name)}}
}
return nil
}), nil
}),
})
}