[pkg-nagios-changes] [Git][nagios-team/icingadb-web][upstream] New upstream version 1.2.1

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Fri Jun 20 14:01:46 BST 2025



Bas Couwenberg pushed to branch upstream at Debian Nagios Maintainer Group / icingadb-web


Commits:
51c7ad84 by Bas Couwenberg at 2025-06-20T14:58:12+02:00
New upstream version 1.2.1
- - - - -


3 changed files:

- library/Icingadb/ProvidedHook/IcingaHealth.php
- library/Icingadb/Widget/Health.php
- + test/php/library/Icingadb/ProvidedHook/IcingaHealthTest.php


Changes:

=====================================
library/Icingadb/ProvidedHook/IcingaHealth.php
=====================================
@@ -16,6 +16,24 @@ class IcingaHealth extends HealthHook
 
     public const REQUIRED_ICINGADB_VERSION = '1.4.0';
 
+    /**
+     * normalizeVersion extracts a version string from Icinga DB's reported
+     * version comparable with REQUIRED_ICINGADB_VERSION via version_compare.
+     *
+     * @param string $version Icinga DB version string to normalize.
+     *
+     * @return string Normalized Icinga DB version string.
+     */
+    public static function normalizeVersion(string $version): string
+    {
+        // Ignore leading "v" when the git tag is used, e.g., "v1.4.0".
+        $version = ltrim($version, 'v');
+        // Ignore everything after "-" used by git describe, e.g., "1.4.0-g...".
+        $version = explode('-', $version, 2)[0];
+
+        return $version;
+    }
+
     /** @var Instance */
     protected $instance;
 
@@ -47,7 +65,11 @@ class IcingaHealth extends HealthHook
             ));
         } elseif (
             ! isset($instance->icingadb_version)
-            || version_compare($instance->icingadb_version, self::REQUIRED_ICINGADB_VERSION, '<')
+            || version_compare(
+                self::normalizeVersion($instance->icingadb_version),
+                self::REQUIRED_ICINGADB_VERSION,
+                '<'
+            )
         ) {
             $this->setState(self::STATE_CRITICAL);
             $this->setMessage(sprintf(


=====================================
library/Icingadb/Widget/Health.php
=====================================
@@ -26,7 +26,11 @@ class Health extends BaseHtmlElement
     {
         if (
             ! isset($this->data->icingadb_version)
-            || version_compare($this->data->icingadb_version, IcingaHealth::REQUIRED_ICINGADB_VERSION, '<')
+            || version_compare(
+                IcingaHealth::normalizeVersion($this->data->icingadb_version),
+                IcingaHealth::REQUIRED_ICINGADB_VERSION,
+                '<'
+            )
         ) {
             $this->addHtml(Html::tag('div', ['class' => 'icinga-health down'], [
                 sprintf(


=====================================
test/php/library/Icingadb/ProvidedHook/IcingaHealthTest.php
=====================================
@@ -0,0 +1,19 @@
+<?php
+
+/* Icinga DB Web | (c) 2025 Icinga GmbH | GPLv2 */
+
+namespace Tests\Icinga\Modules\Icingadb\ProvidedHook;
+
+use Icinga\Module\Icingadb\ProvidedHook\IcingaHealth;
+use PHPUnit\Framework\TestCase;
+
+class IcingaHealthTest extends TestCase
+{
+    public function testNormalizeVersion()
+    {
+        $this->assertEquals('1.4.0', IcingaHealth::normalizeVersion('1.4.0'));
+        $this->assertEquals('1.4.0', IcingaHealth::normalizeVersion('1.4.0-1d5a35da5'));
+        $this->assertEquals('1.4.0', IcingaHealth::normalizeVersion('v1.4.0'));
+        $this->assertEquals('1.4.0', IcingaHealth::normalizeVersion('v1.4.0-1d5a35da5'));
+    }
+}



View it on GitLab: https://salsa.debian.org/nagios-team/icingadb-web/-/commit/51c7ad84e679bcaafa2a30e02d78a665927a4f06

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/icingadb-web/-/commit/51c7ad84e679bcaafa2a30e02d78a665927a4f06
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20250620/955eb9e1/attachment-0001.htm>


More information about the pkg-nagios-changes mailing list