-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from jvanz/issue212
fix(report): Result field is optional.
- Loading branch information
Showing
3 changed files
with
8 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,7 +132,11 @@ func newPolicyReportResult(policy policiesv1.Policy, admissionReview *admissionv | |
} | ||
|
||
var message string | ||
if !errored { | ||
// We need to check if Result is not nil because this field is | ||
// optional. If the policy returns "allowed" to the admissionReview, | ||
// the Result field is not checked by Kubernetes. | ||
// https://pkg.go.dev/k8s.io/[email protected]/admission/v1#AdmissionResponse | ||
if !errored && admissionReview.Response.Result != nil { | ||
message = admissionReview.Response.Result.Message | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters