Bug #18466
closedInherited node prop arrays are replaced not merged contrary to doc
Description
If you have a global parameter or a group property which is an array, and the node property also defined an array, then the node property array override the parent one in place of appending it, contrary to doc here: https://docs.rudder.io/reference/6.1/usage/variables.html#_node_properties
It seems that the most common use case is appending, not overriding, see: https://gitter.im/normation/rudder?at=5fa075ebdc70b5159aea489b
In the best case, we should let user specify what they want with some syntaxe. Or change the default. Or change the documentation.
EDIT: I proposed a more flexible solution where you can specify what merge behavior you choose for Object, Array and String.
The option is like a regex modifier. It is composed of three chars in a (?
and )
:
- first char is one of m
(merge: default), o
(override): behavior for objects,
- second char is one of o
) (override: default), a
(append), p
(prepend): behavior for arrays
- third char is one of o
) (override: default), a
(append), p
(prepend): behavior for strings.
When unspecified, inheritance behavior is (?moo)
, i.e: Merge object, override arrays and strings (current behavior).
So if an inheritance modifier, it is applied to all children until redefined.
Ex: GlobalParam:
(?mao){"a": [1, 2], "s": "a", "x":"x" }
Node param
(?mao){"a": [3, 4], "s": "b", "y":"y" }
Will result in:
(?mao){"a": [1, 2, 3, 4], "s": "b", "x":"x", "y":"y" }