guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: services: zabbix: Support gexps in configuration


From: guix-commits
Subject: branch master updated: services: zabbix: Support gexps in configuration serializer.
Date: Sun, 30 Jan 2022 08:50:11 -0500

This is an automated email from the git hooks/post-receive script.

mbakke pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new ab8b76b735 services: zabbix: Support gexps in configuration serializer.
ab8b76b735 is described below

commit ab8b76b735237b3722f1bff97f096ce48a222867
Author: Marius Bakke <marius@gnu.org>
AuthorDate: Sun Jan 30 13:06:10 2022 +0100

    services: zabbix: Support gexps in configuration serializer.
    
    This makes it possible to do e.g. (include-files (list (local-file 
"foo.conf"))).
    
    * gnu/services/monitoring.scm (serialize-field, serialize-list,
    serialize-include-files, serialize-extra-options): Rewrite as gexps.
    (zabbix-server-config-file, zabbix-agent-config-file): Simplify builders by
    using FORMAT.
---
 gnu/services/monitoring.scm | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm
index ea0f5b8f0e..398fe0bb8b 100644
--- a/gnu/services/monitoring.scm
+++ b/gnu/services/monitoring.scm
@@ -212,13 +212,16 @@ Prometheus.")
                             #\-))))
 
 (define (serialize-field field-name val)
-  (format #t "~a=~a~%" (uglify-field-name field-name) val))
+  #~(format #f "~a=~a~%" #$(uglify-field-name field-name) #$val))
 
 (define (serialize-number field-name val)
   (serialize-field field-name (number->string val)))
 
 (define (serialize-list field-name val)
-  (if (null? val) "" (serialize-field field-name (string-join val ","))))
+  #~(if (null? '#$val)
+        ""
+        #$(serialize-field field-name (string-join val ","))))
+
 
 (define (serialize-string field-name val)
   (if (and (string? val) (string=? val ""))
@@ -233,12 +236,12 @@ Prometheus.")
 (define include-files? list?)
 
 (define (serialize-include-files field-name val)
-  (if (null? val) "" (for-each (cut serialize-field 'include <>) val)))
+  #~(string-append #$@(map (cut serialize-field 'include <>) val)))
 
 (define extra-options? string?)
 
 (define (serialize-extra-options field-name val)
-  (if (null? val) "" (display val)))
+  #~(if (= 0 (string-length #$val)) "" #$(format #f "~a~%" val)))
 
 (define (nginx-server-configuration-list? val)
   (and (list? val) (and-map nginx-server-configuration? val)))
@@ -321,13 +324,9 @@ configuration file."))
    #~(begin
        (call-with-output-file #$output
          (lambda (port)
-           (display "# Generated by 'zabbix-server-service'.\n" port)
-           (display #$(with-output-to-string
-                        (lambda ()
-                          (serialize-configuration
-                           config zabbix-server-configuration-fields)))
-                    port)
-           #t)))))
+           (format port "# Generated by 'zabbix-server-service'.~%")
+           (format port #$(serialize-configuration
+                           config zabbix-server-configuration-fields)))))))
 
 (define (zabbix-server-activation config)
   "Return the activation gexp for CONFIG."
@@ -509,13 +508,9 @@ configuration file."))
    #~(begin
        (call-with-output-file #$output
          (lambda (port)
-           (display "# Generated by 'zabbix-agent-service'.\n" port)
-           (display #$(with-output-to-string
-                        (lambda ()
-                          (serialize-configuration
-                           config zabbix-agent-configuration-fields)))
-                    port)
-           #t)))))
+           (format port "# Generated by 'zabbix-agent-service'.~%")
+           (format port #$(serialize-configuration
+                           config zabbix-agent-configuration-fields)))))))
 
 (define (zabbix-agent-shepherd-service config)
   "Return a <shepherd-service> for Zabbix agent with CONFIG."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]