[icinga-checkins] icinga.org: icingaweb2-module-director/next: CustomVariables: beatify v1.x unsupported vars

git at icinga.org git at icinga.org
Fri Nov 4 19:58:30 CET 2016


Module: icingaweb2-module-director
Branch: next
Commit: 5168f5e8873411baf4ac4578521949c26c779168
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=5168f5e8873411baf4ac4578521949c26c779168

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Nov  4 19:51:02 2016 +0100

CustomVariables: beatify v1.x unsupported vars

---

 .../Director/CustomVariable/CustomVariables.php    |   21 ++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/library/Director/CustomVariable/CustomVariables.php b/library/Director/CustomVariable/CustomVariables.php
index cc0323b..05e1093 100644
--- a/library/Director/CustomVariable/CustomVariables.php
+++ b/library/Director/CustomVariable/CustomVariables.php
@@ -6,7 +6,6 @@ use Icinga\Module\Director\Db;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
 use Icinga\Module\Director\IcingaConfig\IcingaLegacyConfigHelper as c1;
 use Icinga\Module\Director\IcingaConfig\IcingaConfigRenderer;
-use Icinga\Module\Director\Objects\IcingaHostVar;
 use Icinga\Module\Director\Objects\IcingaObject;
 use Countable;
 use Exception;
@@ -17,6 +16,7 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
     /** @var CustomVariable[] */
     protected $storedVars = array();
 
+    /** @var CustomVariable[]  */
     protected $vars = array();
 
     protected $modified = false;
@@ -292,10 +292,7 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
 
         ksort($this->vars);
         foreach ($this->vars as $key => $var) {
-            /** @var CustomVariable $var */
             // TODO: ctype_alnum + underscore?
-            $value = null;
-
             // vars with ARGn will be handled by IcingaObject::renderLegacyCheck_command
             if (substr($key, 0, 3) == 'ARG') {
                 continue;
@@ -303,17 +300,21 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer
 
             switch ($type = $var->getType()) {
                 case 'String':
+                case 'Number':
                     # TODO: Make Prefetchable
-                    $value = $var->toLegacyConfigString();
+                    $out .= c1::renderKeyValue(
+                        '_' . $key,
+                        $var->toLegacyConfigString()
+                    );
                     break;
                 default:
-                    $out .= sprintf("# Unsupported var: %s (%s)\n", $key, $type);
-            }
-
-            if ($value !== null) {
-                $out .= c1::renderKeyValue('_' . $key, $value);
+                    $out .= c1::renderKeyValue(
+                        '# _' . $key,
+                        sprintf('(unsupported: %s)', $type)
+                    );
             }
         }
+
         if ($out !== '') {
             $out = "\n".$out;
         }



More information about the icinga-checkins mailing list