File tree 5 files changed +69
-0
lines changed 5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 14
14
run conftest test --fail-on-warn -p examples/kubernetes/policy examples/kubernetes/service.yaml
15
15
[ " $status " -eq 1 ]
16
16
}
17
+
18
+ @test " Pass when testing a blank namespace" {
19
+ run conftest test --namespace notpresent -p examples/kubernetes/policy examples/kubernetes/deployment.yaml
20
+ [ " $status " -eq 0 ]
21
+ }
22
+
23
+ @test " Fail due to picking up settings from configuration file" {
24
+ cd examples/configfile
25
+ run conftest test deployment.yaml
26
+ [ " $status " -eq 1 ]
27
+ [[ " $output " =~ " Containers must not run as root" ]]
28
+ }
29
+
30
+ @test " Has version flag" {
31
+ run conftest --version
32
+ [ " $status " -eq 0 ]
33
+ }
34
+
35
+ @test " Has help flag" {
36
+ run conftest --help
37
+ [ " $status " -eq 0 ]
38
+ }
Original file line number Diff line number Diff line change
1
+ policy = " test"
2
+ namespace = " conftest"
Original file line number Diff line number Diff line change
1
+ apiVersion : apps/v1
2
+ kind : Deployment
3
+ metadata :
4
+ name : hello-kubernetes
5
+ spec :
6
+ replicas : 3
7
+ selector :
8
+ matchLabels :
9
+ app : hello-kubernetes
10
+ template :
11
+ metadata :
12
+ labels :
13
+ app : hello-kubernetes
14
+ spec :
15
+ containers :
16
+ - name : hello-kubernetes
17
+ image : paulbouwer/hello-kubernetes:1.5
18
+ ports :
19
+ - containerPort : 8080
Original file line number Diff line number Diff line change
1
+ package conftest
2
+
3
+ import data.kubernetes
4
+
5
+
6
+ deny[msg] {
7
+ kubernetes.is_deployment
8
+ not input.spec.template.spec.securityContext.runAsNonRoot = true
9
+ msg = " Containers must not run as root"
10
+ }
11
+
12
+ deny[msg] {
13
+ kubernetes.is_deployment
14
+ not input.spec.selector.matchLabels.app
15
+ not input.spec.selector.matchLabels.release
16
+ msg = " Containers must provide app/release labls for pod selectors"
17
+ }
Original file line number Diff line number Diff line change
1
+ package kubernetes
2
+
3
+ is_service {
4
+ input.kind = " Service"
5
+ }
6
+
7
+ is_deployment {
8
+ input.kind = " Deployment"
9
+ }
You can’t perform that action at this time.
0 commit comments