1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

change RuleStatus values to lowercase

Signed-off-by: Jim Bugwadia <jim@nirmata.com>
This commit is contained in:
Jim Bugwadia 2021-09-30 00:04:13 -07:00
parent 3957a1400e
commit 5b5a85c16a
27 changed files with 44 additions and 44 deletions

View file

@ -16,7 +16,7 @@ resource:
rules:
- name: validate-hostPath
type: Validation
status: Fail
status: fail
`
func Test_parse_yaml(t *testing.T) {

View file

@ -32,19 +32,19 @@ func (s *RuleStatus) String() string {
}
var toString = map[RuleStatus]string{
RuleStatusPass: "Pass",
RuleStatusFail: "Fail",
RuleStatusWarn: "Warning",
RuleStatusError: "Error",
RuleStatusSkip: "Skip",
RuleStatusPass: "pass",
RuleStatusFail: "fail",
RuleStatusWarn: "warning",
RuleStatusError: "error",
RuleStatusSkip: "skip",
}
var toID = map[string]RuleStatus{
"Pass": RuleStatusPass,
"Fail": RuleStatusFail,
"Warning": RuleStatusWarn,
"Error": RuleStatusError,
"Skip": RuleStatusSkip,
"pass": RuleStatusPass,
"fail": RuleStatusFail,
"warning": RuleStatusWarn,
"error": RuleStatusError,
"skip": RuleStatusSkip,
}
// MarshalJSON marshals the enum as a quoted json string

View file

@ -86,7 +86,7 @@ var rawPolicy = []byte(`
}
`)
var rawEngRes = []byte(`{"PatchedResource":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"nginx1","namespace":"default"},"spec":{"containers":[{"image":"nginx","imagePullPolicy":"IfNotPresent","name":"nginx","resources":{"limits":{"cpu":"200m","memory":"100Mi"},"requests":{"cpu":"100m","memory":"50Mi"}}}]}},"PolicyResponse":{"policy":{"name":"pod-requirements","namespace":""},"resource":{"kind":"Pod","apiVersion":"v1","namespace":"default","name":"nginx1","uid":""},"processingTime":974958,"rulesAppliedCount":2,"policyExecutionTimestamp":1630527712,"rules":[{"name":"pods-require-account","type":"Validation","message":"validation error: User pods must include an account for charging. Rule pods-require-account failed at path /metadata/labels/","status":"Fail","processingTime":28833,"ruleExecutionTimestamp":1630527712},{"name":"pods-require-limits","type":"Validation","message":"validation rule 'pods-require-limits' passed.","status":"Pass","processingTime":578625,"ruleExecutionTimestamp":1630527712}],"ValidationFailureAction":"audit"}}`)
var rawEngRes = []byte(`{"PatchedResource":{"apiVersion":"v1","kind":"Pod","metadata":{"name":"nginx1","namespace":"default"},"spec":{"containers":[{"image":"nginx","imagePullPolicy":"IfNotPresent","name":"nginx","resources":{"limits":{"cpu":"200m","memory":"100Mi"},"requests":{"cpu":"100m","memory":"50Mi"}}}]}},"PolicyResponse":{"policy":{"name":"pod-requirements","namespace":""},"resource":{"kind":"Pod","apiVersion":"v1","namespace":"default","name":"nginx1","uid":""},"processingTime":974958,"rulesAppliedCount":2,"policyExecutionTimestamp":1630527712,"rules":[{"name":"pods-require-account","type":"Validation","message":"validation error: User pods must include an account for charging. Rule pods-require-account failed at path /metadata/labels/","status":"fail","processingTime":28833,"ruleExecutionTimestamp":1630527712},{"name":"pods-require-limits","type":"Validation","message":"validation rule 'pods-require-limits' passed.","status":"pass","processingTime":578625,"ruleExecutionTimestamp":1630527712}],"ValidationFailureAction":"audit"}}`)
func Test_buildPolicyReports(t *testing.T) {
os.Setenv("POLICY-TYPE", common.PolicyReport)

View file

@ -26,7 +26,7 @@ expected:
rules:
- name: validate-hostPath
type: Validation
status: Fail
status: fail
`
func Test_parse_yaml(t *testing.T) {

View file

@ -7,4 +7,4 @@ results:
- policy: disallow-latest-tag
rule: missing
resource: test
status: Pass
status: pass

View file

@ -7,11 +7,11 @@ results:
- policy: disallow-latest-tag
rule: require-image-tag
resource: test-require-image-tag-pass
status: Pass
status: pass
- policy: disallow-latest-tag
rule: require-image-tag
resource: test-require-image-tag-fail
status: Fail
status: fail
- policy: disallow-latest-tag
rule: validate-image-tag
resource: test-validate-image-tag-ignore
@ -19,8 +19,8 @@ results:
- policy: disallow-latest-tag
rule: validate-image-tag
resource: test-validate-image-tag-fail
status: Fail
status: fail
- policy: disallow-latest-tag
rule: validate-image-tag
resource: test-validate-image-tag-pass
status: Pass
status: pass

View file

@ -17,5 +17,5 @@ expected:
rules:
- name: pEP
type: Mutation
status: Pass
status: pass
message: successfully process JSON patches

View file

@ -16,5 +16,5 @@ expected:
rules:
- name: disable-servicelink-and-token
type: Mutation
status: Pass
status: pass
message: successfully processed strategic merge patch

View file

@ -17,7 +17,7 @@ expected:
rules:
- name: add-memory-limit
type: Mutation
status: Pass
status: pass
message: successfully processed strategic merge patch
validation:
policyresponse:
@ -33,4 +33,4 @@ expected:
- name: check-cpu-memory-limits
type: Validation
message: validation rule 'check-cpu-memory-limits' passed.
status: Pass
status: pass

View file

@ -18,4 +18,4 @@ expected:
- name: validate-default-proc-mount
type: Validation
message: "validation rule 'validate-default-proc-mount' passed."
status: Pass
status: pass

View file

@ -17,4 +17,4 @@ expected:
- name: prevent-mounting-default-serviceaccount
type: Validation
message: "validation error: Prevent mounting of default service account. Rule prevent-mounting-default-serviceaccount failed at path /spec/serviceAccountName/"
status: Fail
status: fail

View file

@ -17,8 +17,8 @@ expected:
- name: check-readinessProbe-exists
type: Validation
message: validation rule 'check-readinessProbe-exists' passed.
status: Pass
status: pass
- name: check-livenessProbe-exists
type: Validation
message: validation rule 'check-livenessProbe-exists' passed.
status: Pass
status: pass

View file

@ -17,4 +17,4 @@ expected:
- name: validate-selinux-options
type: Validation
message: "validation error: SELinux level is required. Rule validate-selinux-options failed at path /spec/containers/0/securityContext/seLinuxOptions/"
status: Fail
status: fail

View file

@ -18,4 +18,4 @@ expected:
- name: validate-volumes-whitelist
type: Validation
message: "validation rule 'validate-volumes-whitelist' anyPattern[2] passed."
status: Pass
status: pass

View file

@ -20,5 +20,5 @@ expected:
rules:
- name: default-deny-ingress
type: Generation
status: Pass
status: pass
message: created resource NetworkPolicy/devtest/default-deny-ingress

View file

@ -20,7 +20,7 @@ expected:
rules:
- name: generate-resourcequota
type: Generation
status: Pass
status: pass
- name: generate-limitrange
type: Generation
status: Pass
status: pass

View file

@ -17,5 +17,5 @@ expected:
rules:
- name: annotate-empty-dir
type: Mutation
status: Pass
status: pass
message: "successfully processed strategic merge patch"

View file

@ -17,5 +17,5 @@ expected:
rules:
- name: annotate-host-path
type: Mutation
status: Pass
status: pass
message: "successfully processed strategic merge patch"

View file

@ -17,4 +17,4 @@ expected:
- name: validate-hostPath
message: "validation error: Host path volumes are not allowed. Rule validate-hostPath failed at path /spec/volumes/0/hostPath/"
type: Validation
status: Fail
status: fail

View file

@ -16,4 +16,4 @@ expected:
rules:
- name: validate-hostPath
type: Validation
status: Pass
status: pass

View file

@ -16,7 +16,7 @@ expected:
rules:
- name: validate-host-network
type: Validation
status: Pass
status: pass
- name: validate-host-port
type: Validation
status: Fail
status: fail

View file

@ -16,4 +16,4 @@ expected:
rules:
- name: validate-hostPID-hostIPC
type: Validation
status: Fail
status: fail

View file

@ -16,7 +16,7 @@ expected:
rules:
- name: validate-privileged
type: Validation
status: Fail
status: fail
- name: validate-allowPrivilegeEscalation
type: Validation
status: Fail
status: fail

View file

@ -17,4 +17,4 @@ expected:
rules:
- name: validate-sysctls
type: Validation
status: Fail
status: fail

View file

@ -16,4 +16,4 @@ expected:
rules:
- name: validate-automountServiceAccountToken
type: Validation
status: Pass
status: pass

View file

@ -16,4 +16,4 @@ expected:
rules:
- name: validate-ingress
type: Validation
status: Pass
status: pass

View file

@ -16,4 +16,4 @@ expected:
rules:
- name: validate-ingress
type: Validation
status: Fail
status: fail