Report the backend host as the source fact value
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful

This commit is contained in:
2026-10-09 23:46:21 +11:00
parent 0aff1746e2
commit a43e5481f0
9 changed files with 146 additions and 64 deletions
+22
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"io"
"log"
"net"
"net/http"
"net/http/httptest"
"net/url"
@@ -158,6 +159,27 @@ func truncate(t *testing.T, body, limit string) string {
return string(out)
}
// Test backends are reached as hostA/hostB, since the source fact's value is the
// backend host and both httptest servers listen on 127.0.0.1.
const (
hostA = "a.localhost"
hostB = "b.localhost"
)
func withHost(rawURL, host string) string {
u, err := url.Parse(rawURL)
if err != nil || u.Port() == "" {
return rawURL
}
u.Host = net.JoinHostPort(host, u.Port())
return u.String()
}
// hostedConfig is testConfig with the backends reached as hostA and hostB.
func hostedConfig(aURL, bURL, merge string) Config {
return testConfig(withHost(aURL, hostA), withHost(bURL, hostB), merge)
}
func testConfig(aURL, bURL, merge string) Config {
return Config{
Listen: ":0",