fixed issue where nested was lost an in general nested maps did not
work.
This commit is contained in:
parent
47bb4af991
commit
677f7d57ba
@ -61,15 +61,19 @@ func subtract(yaml2 yaml.MapSlice, yaml1 yaml.MapSlice) yaml.MapSlice {
|
||||
v2 := item.Value
|
||||
v1 := yaml1.ToMap()[k]
|
||||
switch {
|
||||
case v2 != nil && v1 == nil:
|
||||
res = append(res, item)
|
||||
case reflect.DeepEqual(v1, v2):
|
||||
// delete is implicit by not copying to the output
|
||||
case Type(v1) == Map && Type(v2) == Map:
|
||||
case reflect.TypeOf(v1) == reflect.TypeOf(yaml.MapSlice{}) &&
|
||||
reflect.TypeOf(v2) == reflect.TypeOf(yaml.MapSlice{}):
|
||||
diff := subtract(v2.(yaml.MapSlice), v1.(yaml.MapSlice))
|
||||
if len(diff) > 0 {
|
||||
res = append(res, item)
|
||||
mi := yaml.MapItem{Key: k, Value: diff}
|
||||
res = append(res, mi)
|
||||
}
|
||||
case Type(v1) == Slice && Type(v2) == Slice:
|
||||
|
||||
// To be improved can be really confusing.
|
||||
v2set := make(map[string]bool)
|
||||
v1set := make(map[string]bool)
|
||||
stringToValue := make(map[any]any)
|
||||
@ -141,7 +145,7 @@ Shows the changes in <file2> compared to <file1>`,
|
||||
}
|
||||
|
||||
cmd.PersistentFlags().IntVarP(&VERBOSITY, "array-output-level",
|
||||
"v", 1, "Array output level: , 1: only show changed/added values, 2 (default) show identical as <UNMODIFIED>, 3: show all values")
|
||||
"v", 1, "Array output level: , 1: only show changed/added values, 2 show identical as <UNMODIFIED>, 3: show all values")
|
||||
|
||||
cmd.Execute()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user