MCPcopy
hub / github.com/homeport/dyff / nodify

Function nodify

pkg/dyff/core_suite_test.go:318–361  ·  view source on GitHub ↗
(obj interface{})

Source from the content-addressed store, hash-verified

316}
317
318func nodify(obj interface{}) *yamlv3.Node {
319 if obj == nil {
320 return nil
321 }
322
323 switch tobj := obj.(type) {
324 case *yamlv3.Node:
325 return tobj
326
327 case []string:
328 return dyff.AsSequenceNode(tobj...)
329
330 case string:
331 return &yamlv3.Node{
332 Kind: yamlv3.ScalarNode,
333 Tag: "!!str",
334 Value: tobj,
335 }
336
337 case int:
338 return &yamlv3.Node{
339 Kind: yamlv3.ScalarNode,
340 Tag: "!!int",
341 Value: strconv.Itoa(tobj),
342 }
343
344 case float64:
345 return &yamlv3.Node{
346 Kind: yamlv3.ScalarNode,
347 Tag: "!!float",
348 Value: strconv.FormatFloat(tobj, 'f', -1, 64),
349 }
350
351 case bool:
352 return &yamlv3.Node{
353 Kind: yamlv3.ScalarNode,
354 Tag: "!!bool",
355 Value: fmt.Sprintf("%v", tobj),
356 }
357 }
358
359 Fail(fmt.Sprintf("Unable to translate %v (%T) into a YAML v3 Node", obj, obj))
360 return nil
361}
362
363func singleDiff(p string, change rune, from, to interface{}) dyff.Diff {
364 return dyff.Diff{

Callers 2

singleDiffFunction · 0.85
doubleDiffFunction · 0.85

Calls 1

AsSequenceNodeFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…