Check backend hosts only when the source fact is enabled, compare them case-insensitively
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:49:42 +11:00
parent a43e5481f0
commit b1d68f5c80
4 changed files with 31 additions and 13 deletions
+3 -10
View File
@@ -13,7 +13,7 @@ import (
// callers need no branch.
type sourceInjector struct {
name string
// hosts maps backend name to the value emitted; an unmapped name is emitted as-is.
// hosts maps backend name to the value emitted.
hosts map[string]string
// inject is false when the query shape rules synthesis out. Suppression of an
// upstream fact of the same name does not depend on it.
@@ -38,13 +38,6 @@ func (si *sourceInjector) claims(factName string) bool {
return si != nil && factName != "" && factName == si.name
}
func (si *sourceInjector) value(backend string) string {
if h, ok := si.hosts[backend]; ok {
return h
}
return backend
}
// injects reports whether this response may carry the synthetic record.
func (si *sourceInjector) injects() bool {
return si != nil && si.inject
@@ -79,7 +72,7 @@ func (si *sourceInjector) factRecord(certname, backend, environment string) json
Environment string `json:"environment"`
Name string `json:"name"`
Value string `json:"value"`
}{Certname: certname, Environment: environment, Name: si.name, Value: si.value(backend)})
}{Certname: certname, Environment: environment, Name: si.name, Value: si.hosts[backend]})
if err != nil {
return nil
}
@@ -96,7 +89,7 @@ func (si *sourceInjector) stamp(raw json.RawMessage, backend string) json.RawMes
if json.Unmarshal(raw, &obj) != nil || obj == nil {
return raw
}
value, err := json.Marshal(si.value(backend))
value, err := json.Marshal(si.hosts[backend])
if err != nil {
return raw
}