Skip to content

Commit

Permalink
httpcaddyfile: Sort skip_hosts for deterministic JSON (#5990)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
francislavoie and mohammed90 committed Dec 18, 2023
1 parent 387545a commit da7d8cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions caddyconfig/httpcaddyfile/httptype.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions caddytest/integration/caddyfile_adapt/log_skip_hosts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ example.com {
"one.example.com": ""
},
"skip_hosts": [
"example.com",
"three.example.com",
"two.example.com",
"example.com"
"two.example.com"
]
}
}
Expand Down

0 comments on commit da7d8cb

Please sign in to comment.