[icinga-checkins] icinga.org: icingaweb2-module-director/feature/nested-apply-rules-12033: AssignRenderer: add renderEquals method...

git at icinga.org git at icinga.org
Sun Oct 23 06:25:33 CEST 2016


Module: icingaweb2-module-director
Branch: feature/nested-apply-rules-12033
Commit: 0a6514928a073a9452cb5470cb3870ffe62213de
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=0a6514928a073a9452cb5470cb3870ffe62213de

Author: Thomas Gelf <thomas at gelf.net>
Date:   Fri Oct 21 18:07:47 2016 +0000

AssignRenderer: add renderEquals method...

...with (hopefully temporarily) hardcoded groups support

---

 library/Director/IcingaConfig/AssignRenderer.php |   23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/library/Director/IcingaConfig/AssignRenderer.php b/library/Director/IcingaConfig/AssignRenderer.php
index 39baaee..298f77f 100644
--- a/library/Director/IcingaConfig/AssignRenderer.php
+++ b/library/Director/IcingaConfig/AssignRenderer.php
@@ -54,6 +54,23 @@ class AssignRenderer
         }
     }
 
+    protected function renderEquals($column, $expression)
+    {
+        if ($column === 'groups') {
+            return sprintf(
+                '%s in %s',
+                $expression,
+                $column
+            );
+        } else {
+            return sprintf(
+                '%s == %s',
+                $column,
+                $expression
+            );
+        }
+    }
+
     protected function renderFilterExpression($filter)
     {
         $column = $filter->getColumn();
@@ -67,11 +84,7 @@ class AssignRenderer
 
         } elseif ($filter instanceof FilterMatch) {
             if (strpos($expression, '*') === false) {
-                return sprintf(
-                    '%s == %s',
-                    $column,
-                    $expression
-                );
+                return $this->renderEquals($column, $expression);
             } else {
                 return sprintf(
                     'match(%s, %s)',



More information about the icinga-checkins mailing list