Commit 6f607c2
committed
feat(orchestrator): let a queue select the git change provider
## Summary
### Why?
The previous change added a change provider that reads a git repository. Nothing could select it: `profiles.yaml` had no `type: git`, and the wiring had no case for one. This connects the two.
### What?
`changeProvider: {type: git, git: {…}}` in `profiles.yaml`, nested under a named block like `github` and `phabricator` are, carrying what a copy of a repository needs: `remoteUrl`, `target`, `repoPath`, and optionally `tokenEnv`/`tokenUser`. `remote` defaults to `origin`, `tokenUser` to `x-access-token`.
Three values are required because none has a default that could be right: there is no public git remote to fall back on, no universal trunk name, and nowhere obvious to keep a copy. The block deliberately reads like Runway's merger block — each service says for itself where its copy fetches from, so a queue's provider and its merger can name the same remote while being configured independently.
**Two queues may share a `repoPath`, and should when they are on the same repository** — that is how they come to share one copy and one lock. Sharing a path while disagreeing about the remote or target is rejected at startup, because whichever queue was built first would silently decide what the other one reads.
**The default `Auth` lives here, not in the extension.** `tokenAuth` reads a named environment variable and writes git an `http.extraheader` fragment inside the repository, mode 0600, included from its config — never into the remote URL, which git echoes back into error messages and from there into logs and dead-letter payloads. The extension only knows it has an `Auth` and calls it; a deployment that mints short-lived tokens or reads a secrets manager replaces this one file's worth of behaviour and changes nothing else. It is applied before each fetch rather than once, which is what lets an expiring credential be refreshed.
A remote that needs no credential gets a nil `Auth` — a local path, or SSH served by the host's own configuration and agent.
**Provisioning now fetches.** It runs at wiring time, and the reason given for that was to fail the misconfigured service rather than bury the failure in a queue's retry loop. Writing the test for it showed the claim was not yet true: initializing a directory and recording a remote succeeds whether or not the remote exists, so a wrong URL would have surfaced later, per message, as a validate failure. Provisioning fetches the target branch, which is the step that actually proves the remote is reachable and the credential works — and it warms the copy, so the first request does not pay for a clone.
`newProfiles` takes a context so that provisioning can be cancelled: it reaches the network during startup, and a shutdown then should stop it rather than wait it out.
Still nothing selects it — no demo queue is switched over and the orchestrator image has no git binary yet. Those are the next two steps.
## Test Plan
- ✅ the seam test: configuration in, a provider out that reports `pkg/a/one.go` with 2 added lines from a repository the test built — which only passes if the config block, provisioning, the injected auth and the factory case all line up
- ✅ an unreachable remote fails `newProfiles`. This is the test that found the gap above; before provisioning fetched, it passed startup and would have failed per message instead
- ✅ defaults applied (`remote`, `tokenUser`) and each of the three required values rejected when missing
- ✅ two queues sharing a `repoPath` with different remotes are rejected; two that agree are allowed, since sharing a copy is the point
- ✅ `make test`, `make lint`, `make gazelle`
The config block is nested under `git:` rather than flat as the plan sketched. Flat would have matched `merge.yaml` more literally, but this file's own grammar is a named block per provider, and consistency inside the file a reader is editing seemed worth more than symmetry with a file in another service.1 parent 172c4fc commit 6f607c2
7 files changed
Lines changed: 475 additions & 7 deletions
File tree
- service/submitqueue/orchestrator/server
- submitqueue/extension/changeprovider/git
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
101 | 103 | | |
102 | 104 | | |
103 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
104 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
105 | 113 | | |
| 114 | + | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| |||
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
| 129 | + | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
128 | 160 | | |
129 | 161 | | |
130 | 162 | | |
| |||
269 | 301 | | |
270 | 302 | | |
271 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
272 | 339 | | |
273 | 340 | | |
274 | 341 | | |
| |||
317 | 384 | | |
318 | 385 | | |
319 | 386 | | |
| 387 | + | |
| 388 | + | |
320 | 389 | | |
321 | 390 | | |
322 | 391 | | |
| |||
343 | 412 | | |
344 | 413 | | |
345 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
346 | 440 | | |
347 | 441 | | |
348 | 442 | | |
| |||
0 commit comments