@@ -147,14 +147,14 @@ func WalkTemplates(ctx context.Context, decoder runtime.Decoder, req *runtimehoo
147
147
var patch []byte
148
148
switch options .patchFormat {
149
149
case runtimehooksv1 .JSONPatchType :
150
- patch , err = createJSONPatch (original , modified )
150
+ patch , err = createJSONPatch (requestItem . Object . Raw , modified )
151
151
if err != nil {
152
152
resp .Status = runtimehooksv1 .ResponseStatusFailure
153
153
resp .Message = err .Error ()
154
154
return
155
155
}
156
156
case runtimehooksv1 .JSONMergePatchType :
157
- patch , err = createJSONMergePatch (original , modified )
157
+ patch , err = createJSONMergePatch (requestItem . Object . Raw , modified )
158
158
if err != nil {
159
159
resp .Status = runtimehooksv1 .ResponseStatusFailure
160
160
resp .Message = err .Error ()
@@ -174,12 +174,7 @@ func WalkTemplates(ctx context.Context, decoder runtime.Decoder, req *runtimehoo
174
174
}
175
175
176
176
// createJSONPatch creates a RFC 6902 JSON patch from the original and the modified object.
177
- func createJSONPatch (original , modified runtime.Object ) ([]byte , error ) {
178
- marshalledOriginal , err := json .Marshal (original )
179
- if err != nil {
180
- return nil , errors .Errorf ("failed to marshal original object: %v" , err )
181
- }
182
-
177
+ func createJSONPatch (marshalledOriginal []byte , modified runtime.Object ) ([]byte , error ) {
183
178
marshalledModified , err := json .Marshal (modified )
184
179
if err != nil {
185
180
return nil , errors .Errorf ("failed to marshal modified object: %v" , err )
@@ -199,12 +194,7 @@ func createJSONPatch(original, modified runtime.Object) ([]byte, error) {
199
194
}
200
195
201
196
// createJSONMergePatch creates a RFC 7396 JSON merge patch from the original and the modified object.
202
- func createJSONMergePatch (original , modified runtime.Object ) ([]byte , error ) {
203
- marshalledOriginal , err := json .Marshal (original )
204
- if err != nil {
205
- return nil , errors .Errorf ("failed to marshal original object: %v" , err )
206
- }
207
-
197
+ func createJSONMergePatch (marshalledOriginal []byte , modified runtime.Object ) ([]byte , error ) {
208
198
marshalledModified , err := json .Marshal (modified )
209
199
if err != nil {
210
200
return nil , errors .Errorf ("failed to marshal modified object: %v" , err )
0 commit comments