[Bug 270120] www/caddy: support JSON config files

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 11 Mar 2023 18:50:07 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270120

            Bug ID: 270120
           Summary: www/caddy: support JSON config files
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: adamw@FreeBSD.org
          Reporter: pawel.krawczyk@hush.com
             Flags: maintainer-feedback?(adamw@FreeBSD.org)
          Assignee: adamw@FreeBSD.org

Caddy v2 native configuration format is plain JSON, which is not supported by
the current logic in /usr/local/etc/rc.d/caddy which always sets the --adapter
flag. With this patch, when caddy_adapter="json", Caddy will start with the
config file path but without --adapter, which will imply the JSON format:

diff --git a/www/caddy/files/caddy.in b/www/caddy/files/caddy.in
index 85251ab1c..4314db8d1 100644
--- a/www/caddy/files/caddy.in
+++ b/www/caddy/files/caddy.in
@@ -54,7 +54,11 @@ load_rc_config $name
 export XDG_CONFIG_HOME XDG_DATA_HOME

 command="${caddy_command}"
-caddy_flags="--config ${caddy_config} --adapter ${caddy_adapter}"
+if [ "${caddy_adapter}" = "json" ]; then
+        caddy_flags="--config ${caddy_config}"
+else
+        caddy_flags="--config ${caddy_config} --adapter ${caddy_adapter}"  
+fi
 pidfile="/var/run/${name}/${name}.pid"

 required_files="${caddy_config} ${caddy_command}"

-- 
You are receiving this mail because:
You are the assignee for the bug.