fix(binding): add Owner/Repo pin, fixing multi-repo dispatch
Root-cause fix for the correctness gap named in archie-core-t2db.8: resolveBindingRepo refused to dispatch with zero or multiple configured repos, meaning a multi-repo deployment could never use bindings at all. - binding.Binding gains optional Owner/Repo fields; Validate rejects setting only one (a pin is a complete pair or not a pin at all). - Persisted as new owner/repo columns (NOT NULL DEFAULT '', additive -- no migration needed since bindings is a CREATE TABLE IF NOT EXISTS with no existing deployment yet). - resolveBindingRepo now takes the binding: a pinned binding dispatches to its own owner/repo unconditionally; an unpinned binding keeps today's single-configured-repo fallback (0 or 2+ repos still refuses, unchanged -- verified by a dedicated regression test, not just assumed preserved). - Wired through the API request/response shape (create/update accept and return owner/repo); no repo-existence validation against config added -- smallest workable change, not the named bug. Red-green throughout: 8 new tests across domain/store/daemon/webui layers, each proven to fail before the corresponding implementation step. Zero regressions in existing binding/dispatch test suites. Dashboard UI to expose this (the other half of t2db.8) is unstarted -- this closes the backend correctness gap only.
This commit is contained in:
1 parent
4a62df09f2
commit
7705fda777
8 files changed
+274
-29
No files matched your search
@@ -18,7 +18,13 @@ type bindingRequest struct {
|
||||
Matcher binding.Matcher `json:"matcher"`
|
||||
MappingID int64 `json:"mapping_id"`
|
||||
Workflow string `json:"workflow"`
|
||||
Secret string `json:"secret"`
|
||||
// Owner and Repo optionally pin the binding to one configured repo,
|
||||
// for multi-repo deployments. Both empty is valid (falls back to the
|
||||
// daemon's single-configured-repo behaviour); binding.Validate
|
||||
// rejects setting only one.
|
||||
Owner string `json:"owner"`
|
||||
Repo string `json:"repo"`
|
||||
Secret string `json:"secret"`
|
||||
}
|
||||
|
||||
func (s *Server) handleBindingsList(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -55,6 +61,8 @@ func (s *Server) handleBindingCreate(w http.ResponseWriter, r *http.Request) {
|
||||
Matcher: req.Matcher,
|
||||
MappingID: req.MappingID,
|
||||
Workflow: req.Workflow,
|
||||
Owner: req.Owner,
|
||||
Repo: req.Repo,
|
||||
Secret: req.Secret,
|
||||
Status: binding.Normalize(binding.StatusDraft),
|
||||
}
|
||||
@@ -132,6 +140,8 @@ func (s *Server) handleBindingUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
Matcher: req.Matcher,
|
||||
MappingID: req.MappingID,
|
||||
Workflow: req.Workflow,
|
||||
Owner: req.Owner,
|
||||
Repo: req.Repo,
|
||||
Secret: req.Secret,
|
||||
}
|
||||
if err := b.Validate(); err != nil {
|
||||
|
||||
Reference in new issue
Block a user