-
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 #336 from viccuad/fix-result-response
fix: Record errored AdmissionReview.Response as errors and not failures
- Loading branch information
Showing
3 changed files
with
70 additions
and
21 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 |
---|---|---|
|
@@ -141,7 +141,9 @@ func newPolicyReportResult(policy policiesv1.Policy, admissionReview *admissionv | |
// 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 { | ||
if admissionReview.Response != nil && admissionReview.Response.Result != nil { | ||
// Mesage contains the human-readable error message if Response.Result.Code == 500 | ||
// or the reason why the policy returned a failure | ||
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