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 <msaa1990@gmail.com>

* Fix test

* Bah

---------

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
This commit is contained in:
Francis LavoieandMohammed Al Sahaf authored and GitHub committed 2023-12-18 12:54:52 -07:00
1 parent 387545a895
commit da7d8cb26d
2 files changed
+7 -2

No files matched your search

+5
View File
@@ -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)
@@ -66,9 +66,9 @@ example.com {
"one.example.com": ""
},
"skip_hosts": [
"example.com",
"three.example.com",
"two.example.com",
"example.com"
"two.example.com"
]
}
}