Render Icinga config helpers with safe globals access

globals[key] works, although it wasn't documented how it
behaves in the case when this field doesn't exist.

Previously this has been a dictionary which silently returns
null if the key doesn't exist. With v2.10, globals turned
into a namespace which throws an error if not existing (which is
the correct behaviour).

In order to avoid configuration errors with 2.10, this is changed
into `contains()` which has been sitting in dictionaries since 2014.
So this patch ensures compatibility with older versions as well.
This commit is contained in:
Michael Friedrich 2018-09-27 08:40:00 +02:00 committed by Thomas Gelf
parent f32f010d5b
commit bb81de8b84

View File

@ -534,7 +534,7 @@ globals.directorWarnOnceForThresholds = function() {
return sprintf( return sprintf(
' '
const DirectorOverrideTemplate = "%s" const DirectorOverrideTemplate = "%s"
if (! globals[DirectorOverrideTemplate]) { if (! globals.contains(DirectorOverrideTemplate)) {
const DirectorOverrideVars = "%s" const DirectorOverrideVars = "%s"
globals.directorWarnedOnceForServiceWithoutHost = false; globals.directorWarnedOnceForServiceWithoutHost = false;