MCPcopy Index your code
hub / github.com/databus23/helm-diff / createNodePatch

Function createNodePatch

diff/structured.go:314–336  ·  view source on GitHub ↗
(oldNode, newNode interface{})

Source from the content-addressed store, hash-verified

312}
313
314func createNodePatch(oldNode, newNode interface{}) (interface{}, error) {
315 oldJSON, err := json.Marshal(oldNode)
316 if err != nil {
317 return nil, err
318 }
319 newJSON, err := json.Marshal(newNode)
320 if err != nil {
321 return nil, err
322 }
323 patchBytes, err := jsonpatch.CreateMergePatch(oldJSON, newJSON)
324 if err != nil {
325 return nil, err
326 }
327 trimmed := bytes.TrimSpace(patchBytes)
328 if len(trimmed) == 0 || bytes.Equal(trimmed, []byte("{}")) {
329 return nil, nil
330 }
331 var patch interface{}
332 if err := json.Unmarshal(patchBytes, &patch); err != nil {
333 return nil, err
334 }
335 return patch, nil
336}
337
338func splitTokens(tokens []string) (string, string) {
339 if len(tokens) == 0 {

Callers 1

diffArrayNodesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected