Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 203 forks source link

Custom Variable inheritance for array-type variable #1605

Open chas0rde opened 6 years ago

chas0rde commented 6 years ago

Expected Behavior

I would think it would make sense that e.g. within template inheritance, custom variables of array-type are appended down the inheritance path

e.g.: Tpl-a-default has Custom-Var "services" assigned with "service-a" and "service-b" Tpl-a-more-specific imports Tpl-a-default and has "services" assigned with "service-c"

In my understanding a host created from that tpl should have all three values set

Current Behavior

Only the last assignment is used

Possible Solution

Make inheritance work here. Maybe it would be a good idea to have a parameter on custom-fields that enables/disables inheritance for this variabl. If enabled above would happen. If disabled only the last assignment would pull (though I fear you guys thinks this is not very intuitive and therefore not working for everyone)

Steps to Reproduce (for bugs)

Your Environment

inmediasit commented 5 years ago

I'd like to back @chas0rde on this one and am honestly surprised this isn't already the case. I get where @Thomas-Gelf is coming from with the current behaviour: it represents the classical class inheritance in computer programming, e.g. if the child class has the same attribute override the corresponding parent class attribute. I get it: it makes perfect sense, in programming that is. However, it would be way more practical if arrays would get appended instead. Taking into consideration that icinga itself supports such a thing should make one at least consider adding the functionality, even if it isn't enabled by default.

The following works in icinga:

<1> => arr = ["test", "test2"]
[ "test", "test2" ]
<2> => arr += ["test3"]
[ "test", "test2", "test3" ]

@Thomas-Gelf I'm no php expert mysqlf but I bet I could come up with a PR that implements this in a couple of hours if I tried. If you don't plan to implement it yourself, would you at least be willing to merge my PR?