Skip to content

Commit 6acc75b

Browse files
author
Chao Xu
committed
Only set admission review reponse patch type if the patch is not empty
1 parent 2a17cfb commit 6acc75b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

test/images/agnhost/webhook/configmap.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ func mutateConfigmaps(ar v1.AdmissionReview) *v1.AdmissionResponse {
9797
reviewResponse.Patch = []byte(configMapPatch2)
9898
}
9999

100-
pt := v1.PatchTypeJSONPatch
101-
reviewResponse.PatchType = &pt
100+
if len(reviewResponse.Patch) != 0 {
101+
pt := v1.PatchTypeJSONPatch
102+
reviewResponse.PatchType = &pt
103+
}
102104

103105
return &reviewResponse
104106
}

test/images/agnhost/webhook/customresource.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ func mutateCustomResource(ar v1.AdmissionReview) *v1.AdmissionResponse {
5656
if cr.Data["mutation-stage-1"] == "yes" {
5757
reviewResponse.Patch = []byte(customResourcePatch2)
5858
}
59-
pt := v1.PatchTypeJSONPatch
60-
reviewResponse.PatchType = &pt
59+
if len(reviewResponse.Patch) != 0 {
60+
pt := v1.PatchTypeJSONPatch
61+
reviewResponse.PatchType = &pt
62+
}
6163
return &reviewResponse
6264
}
6365

0 commit comments

Comments
 (0)