all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: 33836@debbugs.gnu.org
Subject: [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages.
Date: Fri,  1 Mar 2019 01:40:01 +0300	[thread overview]
Message-ID: <20190228224001.27182-3-go.wigust@gmail.com> (raw)
In-Reply-To: <20190228224001.27182-1-go.wigust@gmail.com>

* gnu/services/monitoring.scm (zabbix-front-end-config): Show location in
messages.
---
 gnu/services/monitoring.scm | 57 +++++++++++++++++++++----------------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index 685641f110..101222bf2e 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Sou Bunnbu <iyzsong@member.fsf.org>
 ;;; Copyright © 2018 Gábor Boskovits <boskovits@gmail.com>
-;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2018, 2019 Oleg Pykhalov <go.wigust@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -29,7 +29,8 @@
   #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix records)
-  #:use-module ((guix ui) #:select (display-hint))
+  #:use-module (guix utils)
+  #:use-module ((guix ui) #:select (display-hint G_))
   #:use-module (ice-9 match)
   #:use-module (ice-9 rdelim)
   #:use-module (srfi srfi-26)
@@ -509,13 +510,12 @@ create it manually.")
    (number 10051)
    "Zabbix server port."))
 
-(define zabbix-front-end-config
-  (match-lambda
-    (($ <zabbix-front-end-configuration>
-        _ db-host db-port db-name db-user db-password db-secret-file
-        zabbix-host zabbix-port)
-     (mixed-text-file "zabbix.conf.php"
-                      "\
+(define (zabbix-front-end-config config)
+  (match-record config <zabbix-front-end-configuration>
+    (%location db-host db-port db-name db-user db-password db-secret-file
+               zabbix-host zabbix-port)
+    (mixed-text-file "zabbix.conf.php"
+                     "\
 <?php
 // Zabbix GUI configuration file.
 global $DB;
@@ -525,20 +525,29 @@ $DB['SERVER']   = '" db-host "';
 $DB['PORT']     = '" (number->string db-port) "';
 $DB['DATABASE'] = '" db-name "';
 $DB['USER']     = '" db-user "';
-$DB['PASSWORD'] = '" (if (string-null? db-password)
-                         (if (string-null? db-secret-file)
-                             (raise (condition
-                                     (&message
-                                      (message "\
-you must provide either 'db-secret-file' or 'db-password'"))))
-                             (string-trim-both
-                              (with-input-from-file db-secret-file
-                                read-string)))
-                         (begin
-                           (display-hint "\
-Consider using @code{db-secret-file} instead of @code{db-password} and unset
-@code{db-password} for security in @code{zabbix-front-end-configuration}.")
-                           db-password)) "';
+$DB['PASSWORD'] = '" (let ((file (location-file %location))
+                           (line (location-line %location))
+                           (column (location-column %location)))
+                       (if (string-null? db-password)
+                           (if (string-null? db-secret-file)
+                               (raise (make-compound-condition
+                                       (condition
+                                        (&message
+                                         (message
+                                          (format #f "no '~A' or '~A' field in your '~A' record"
+                                                  'db-secret-file 'db-password
+                                                  'zabbix-front-end-configuration))))
+                                       (condition
+                                        (&error-location
+                                         (location %location)))))
+                               (string-trim-both
+                                (with-input-from-file db-secret-file
+                                  read-string)))
+                           (begin
+                             (display-hint (format #f (G_ "~a:~a:~a: ~a:
+Consider using @code{db-secret-file} instead of @code{db-password} for better
+security.") file line column 'zabbix-front-end-configuration))
+                             db-password))) "';
 
 // Schema name. Used for IBM DB2 and PostgreSQL.
 $DB['SCHEMA'] = '';
@@ -548,7 +557,7 @@ $ZBX_SERVER_PORT = '" (number->string zabbix-port) "';
 $ZBX_SERVER_NAME = '';
 
 $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
-"))))
+")))
 
 (define %maintenance.inc.php
   ;; Empty php file to allow us move zabbix-frontend configs to ‘/etc/zabbix’
-- 
2.20.1

  parent reply	other threads:[~2019-02-28 22:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22 20:38 [bug#33836] [PATCH 0/2] location in define-configuration Oleg Pykhalov
2018-12-22 20:42 ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-22 20:42   ` [bug#33836] [PATCH 2/2] services: zabbix-front-end: Show location in messages Oleg Pykhalov
2018-12-23 14:21   ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-23 15:36     ` [bug#33836] [PATCH] services: zabbix-front-end: Show location in messages Oleg Pykhalov
2018-12-26 17:31       ` Ludovic Courtès
2018-12-23 15:40     ` [bug#33836] [PATCH 1/2] services: configuration: Add location Oleg Pykhalov
2018-12-26 17:30       ` Ludovic Courtès
2019-02-15 22:24         ` Ludovic Courtès
2019-02-28 22:39           ` [bug#33836] [PATCH 0/2] Apply suggestions Oleg Pykhalov
2019-02-28 22:40             ` [bug#33836] [PATCH 1/2] services: configuration: Add '%location' Oleg Pykhalov
2019-02-28 22:40             ` Oleg Pykhalov [this message]
2019-03-10 17:21             ` [bug#33836] [PATCH 0/2] Apply suggestions Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190228224001.27182-3-go.wigust@gmail.com \
    --to=go.wigust@gmail.com \
    --cc=33836@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.