Skip to content

Commit

Permalink
PolicyReport CRD Mapping Update (#25)
Browse files Browse the repository at this point in the history
* Support v1alpha2 "result" property name für PolicyResults
  • Loading branch information
fjogeleit authored Apr 20, 2021
1 parent dfa12c7 commit 6e33bde
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions charts/policy-reporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description: |
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
type: application
version: 1.2.0
appVersion: 1.2.0
version: 1.2.1
appVersion: 1.2.1

dependencies:
- name: monitoring
Expand Down
2 changes: 1 addition & 1 deletion charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image:
repository: fjogeleit/policy-reporter
pullPolicy: IfNotPresent
tag: 1.2.0
tag: 1.2.1

imagePullSecrets: []

Expand Down
9 changes: 8 additions & 1 deletion pkg/kubernetes/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ func (m *mapper) mapResult(result map[string]interface{}) report.Result {
}
}

status := result["status"].(report.Status)
var status report.Status

if s, ok := result["status"]; ok {
status = s.(report.Status)
}
if r, ok := result["result"]; ok {
status = r.(report.Status)
}

r := report.Result{
Message: result["message"].(string),
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubernetes/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var clusterPolicyMap = map[string]interface{}{
"results": []interface{}{
map[string]interface{}{
"message": "message",
"status": "fail",
"result": "fail",
"scored": true,
"policy": "required-label",
"rule": "app-label-required",
Expand Down

0 comments on commit 6e33bde

Please sign in to comment.