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 Lavoie 2023-12-18 14:54:52 -05:00 committed by GitHub
parent 387545a895
commit da7d8cb26d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

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)

View File

@ -66,9 +66,9 @@ example.com {
"one.example.com": ""
},
"skip_hosts": [
"example.com",
"three.example.com",
"two.example.com",
"example.com"
"two.example.com"
]
}
}