aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2023-12-18 14:54:52 -0500
committerGitHub <[email protected]>2023-12-18 12:54:52 -0700
commitda7d8cb26d97d8b797732cc0dcb697edffb693cd (patch)
tree8b9167b392f20b09af06568008ef2641adf201b9
parent387545a895ea71ae9f4f4e512dca136f92e45a74 (diff)
downloadcaddy-da7d8cb26d97d8b797732cc0dcb697edffb693cd.tar.gz
caddy-da7d8cb26d97d8b797732cc0dcb697edffb693cd.zip
httpcaddyfile: Sort skip_hosts for deterministic JSON (#5990)
* httpcaddyfile: Sort skip_hosts for deterministic JSON * Update caddyconfig/httpcaddyfile/httptype.go Co-authored-by: Mohammed Al Sahaf <[email protected]> * Fix test * Bah --------- Co-authored-by: Mohammed Al Sahaf <[email protected]>
-rw-r--r--caddyconfig/httpcaddyfile/httptype.go5
-rw-r--r--caddytest/integration/caddyfile_adapt/log_skip_hosts.txt4
2 files changed, 7 insertions, 2 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go
index c82d92efc..cb3095a16 100644
--- a/caddyconfig/httpcaddyfile/httptype.go
+++ b/caddyconfig/httpcaddyfile/httptype.go
@@ -820,6 +820,11 @@ func (st *ServerType) serversFromPairings(
}
}
+ // sort for deterministic JSON output
+ if srv.Logs != nil {
+ slices.Sort(srv.Logs.SkipHosts)
+ }
+
// a server cannot (natively) serve both HTTP and HTTPS at the
// same time, so make sure the configuration isn't in conflict
err := detectConflictingSchemes(srv, p.serverBlocks, options)
diff --git a/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt b/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
index 25e4bd1c2..8fdd57156 100644
--- a/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
+++ b/caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
@@ -66,9 +66,9 @@ example.com {
"one.example.com": ""
},
"skip_hosts": [
+ "example.com",
"three.example.com",
- "two.example.com",
- "example.com"
+ "two.example.com"
]
}
}