Merge pull request #87781 from caesarxuchao/fix-webhook-image-bugs

Only set admission review reponse patch type if the patch is not empty
This commit is contained in:
Kubernetes Prow Robot 2020-02-05 01:08:23 -08:00 committed by GitHub
commit 8f5e8279f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -97,8 +97,10 @@ func mutateConfigmaps(ar v1.AdmissionReview) *v1.AdmissionResponse {
reviewResponse.Patch = []byte(configMapPatch2)
}
pt := v1.PatchTypeJSONPatch
reviewResponse.PatchType = &pt
if len(reviewResponse.Patch) != 0 {
pt := v1.PatchTypeJSONPatch
reviewResponse.PatchType = &pt
}
return &reviewResponse
}

View File

@ -56,8 +56,10 @@ func mutateCustomResource(ar v1.AdmissionReview) *v1.AdmissionResponse {
if cr.Data["mutation-stage-1"] == "yes" {
reviewResponse.Patch = []byte(customResourcePatch2)
}
pt := v1.PatchTypeJSONPatch
reviewResponse.PatchType = &pt
if len(reviewResponse.Patch) != 0 {
pt := v1.PatchTypeJSONPatch
reviewResponse.PatchType = &pt
}
return &reviewResponse
}