File tree Expand file tree Collapse file tree 3 files changed +65
-7
lines changed
preflight-packages/examples.jetstack.io/aks_basic Expand file tree Collapse file tree 3 files changed +65
-7
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,15 @@ bundle-all-platforms:
7171
7272# Packages
7373
74- package-test :
75- cd $(ROOT_DIR ) && go run ./main.go package test ./preflight-packages/examples.jetstack.io
74+ packages-lint :
75+ cd $(ROOT_DIR ) && \
76+ go run . package lint $(ROOT_DIR ) /preflight-packages/jetstack.io/pods && \
77+ go run . package lint $(ROOT_DIR ) /preflight-packages/examples.jetstack.io/aks_basic && \
78+ go run . package lint $(ROOT_DIR ) /preflight-packages/examples.jetstack.io/gke_basic
79+
80+ packages-test :
81+ cd $(ROOT_DIR ) && \
82+ go run . package test $(ROOT_DIR ) /preflight-packages/examples.jetstack.io
7683
7784# Docker image
7885
@@ -96,7 +103,7 @@ export PATH:=$(GOPATH)/bin:$(PATH)
96103ci-deps :
97104 go install golang.org/x/lint/golint
98105
99- ci-test : ci-deps test lint
106+ ci-test : ci-deps test lint packages-test packages-lint
100107
101108ci-build : ci-test build build-docker-image build-all-platforms bundle-all-platforms push-docker-image-canary
102109
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ package aks_basic
33# See https://github.com/jetstack/preflight/blob/master/docs/datagatherers/aks.md for more details
44import input.aks as aks
55
6- # Rule 'rbac_enabled'
7- default preflight_rbac_enabled = false
8- preflight_rbac_enabled {
9- aks.Cluster.properties.enableRBAC == true
6+ # RBAC Enabled
7+ rbac_enabled[message] {
8+ not aks.Cluster.properties.enableRBAC == true
9+ message := " rbac is not enabled "
1010}
Original file line number Diff line number Diff line change 1+ package aks_basic
2+
3+ assert_allowed (output) = output {
4+ trace (sprintf (" GOT: %s" , [concat (" ," , output)]))
5+ trace (" WANT: empty set" )
6+ output == set ()
7+ }
8+
9+ assert_violates (output, messages) = output {
10+ trace (sprintf (" GOT: %s" , [concat (" ," , output)]))
11+ trace (sprintf (" WANT: %s" , [concat (" ," , messages)]))
12+ output == messages
13+ }
14+
15+ cluster (x) = y { y := {" aks" : {" Cluster" : x }} }
16+
17+ # RBAC Enabled
18+ test_rbac_enabled_enabled {
19+ output := rbac_enabled with input as cluster (
20+ {
21+ " properties" : {
22+ " enableRBAC" : true
23+ }
24+ }
25+ )
26+ assert_allowed (output)
27+ }
28+ test_rbac_enabled_disabled {
29+ output := rbac_enabled with input as cluster (
30+ {
31+ " properties" : {
32+ " enableRBAC" : false
33+ }
34+ }
35+ )
36+ assert_violates (output,
37+ {
38+ " rbac is not enabled"
39+ }
40+ )
41+ }
42+ test_rbac_enabled_missing {
43+ output := rbac_enabled with input as cluster (
44+ {}
45+ )
46+ assert_violates (output,
47+ {
48+ " rbac is not enabled"
49+ }
50+ )
51+ }
You can’t perform that action at this time.
0 commit comments