@caelo-cms/provisioning 0.12.5 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/admin-internal.d.ts +1 -1
  2. package/dist/agent-db.js +192 -130
  3. package/dist/cli-routing.d.ts.map +1 -1
  4. package/dist/cli-routing.js +2 -1
  5. package/dist/cli-routing.js.map +1 -1
  6. package/dist/cli.js +15 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/gcloud.d.ts +32 -1
  9. package/dist/gcloud.d.ts.map +1 -1
  10. package/dist/gcloud.js +59 -7
  11. package/dist/gcloud.js.map +1 -1
  12. package/dist/infra-contract.d.ts +1 -1
  13. package/dist/infra-contract.d.ts.map +1 -1
  14. package/dist/infra-contract.js +9 -1
  15. package/dist/infra-contract.js.map +1 -1
  16. package/dist/upgrader-iam-preflight.d.ts.map +1 -1
  17. package/dist/upgrader-iam-preflight.js +8 -1
  18. package/dist/upgrader-iam-preflight.js.map +1 -1
  19. package/dist/upgrader-setup.d.ts +19 -0
  20. package/dist/upgrader-setup.d.ts.map +1 -1
  21. package/dist/upgrader-setup.js +78 -56
  22. package/dist/upgrader-setup.js.map +1 -1
  23. package/dist/wizard.d.ts +6 -0
  24. package/dist/wizard.d.ts.map +1 -1
  25. package/dist/wizard.js +4 -0
  26. package/dist/wizard.js.map +1 -1
  27. package/dist/wizards/gcp-billing.d.ts +81 -0
  28. package/dist/wizards/gcp-billing.d.ts.map +1 -0
  29. package/dist/wizards/gcp-billing.js +117 -0
  30. package/dist/wizards/gcp-billing.js.map +1 -0
  31. package/dist/wizards/gcp-firebase.d.ts +2 -0
  32. package/dist/wizards/gcp-firebase.d.ts.map +1 -1
  33. package/dist/wizards/gcp-firebase.js +1 -0
  34. package/dist/wizards/gcp-firebase.js.map +1 -1
  35. package/dist/wizards/gcp-install-job.d.ts +3 -0
  36. package/dist/wizards/gcp-install-job.d.ts.map +1 -1
  37. package/dist/wizards/gcp-install-job.js +5 -1
  38. package/dist/wizards/gcp-install-job.js.map +1 -1
  39. package/dist/wizards/gcp.d.ts +6 -0
  40. package/dist/wizards/gcp.d.ts.map +1 -1
  41. package/dist/wizards/gcp.js +68 -36
  42. package/dist/wizards/gcp.js.map +1 -1
  43. package/package.json +2 -2
  44. package/src/admin-internal.ts +1 -1
  45. package/src/cli-routing.test.ts +1 -1
  46. package/src/cli-routing.ts +2 -1
  47. package/src/cli.ts +16 -1
  48. package/src/gcloud.test.ts +67 -0
  49. package/src/gcloud.ts +78 -11
  50. package/src/infra-contract.test.ts +4 -3
  51. package/src/infra-contract.ts +9 -1
  52. package/src/upgrader-iam-preflight.test.ts +49 -42
  53. package/src/upgrader-iam-preflight.ts +8 -0
  54. package/src/upgrader-job.test.ts +1 -0
  55. package/src/upgrader-setup.test.ts +2 -0
  56. package/src/upgrader-setup.ts +86 -55
  57. package/src/wizard.ts +10 -0
  58. package/src/wizards/gcp-billing.test.ts +260 -0
  59. package/src/wizards/gcp-billing.ts +150 -0
  60. package/src/wizards/gcp-firebase.ts +3 -0
  61. package/src/wizards/gcp-install-job.ts +7 -1
  62. package/src/wizards/gcp.ts +86 -43
@@ -20,9 +20,10 @@ describe("infrastructure contract steps", () => {
20
20
  );
21
21
  });
22
22
 
23
- it("is at 27: public_role revoke (3), URL-map redirects role (4), no gateway cms_admin login (5), ops-bucket list (6), gateway proxy hops (7), quality-audit job (8), converge job (9), remote MCP (10), Google sign-in (11), project-level sign-in client (12), edge security headers (13), capture job (14), database verify-full TLS (15), MCP-Auth-Proxy (16), staging database (17), scheduler tick (18), scheduler tick as JSON (19), staging gateway (20), gateway budget and plain-gcp repairs (21), per-path Cloud Armor rules (22), site security headers on the backend bucket (23), the static bucket read for those headers (24), the quality-audit runner (25), the site-import crawler (26), the build carrier (27)", () => {
24
- expect(INFRA_CONTRACT_VERSION).toBe(27);
23
+ it("is at 28: public_role revoke (3), URL-map redirects role (4), no gateway cms_admin login (5), ops-bucket list (6), gateway proxy hops (7), quality-audit job (8), converge job (9), remote MCP (10), Google sign-in (11), project-level sign-in client (12), edge security headers (13), capture job (14), database verify-full TLS (15), MCP-Auth-Proxy (16), staging database (17), scheduler tick (18), scheduler tick as JSON (19), staging gateway (20), gateway budget and plain-gcp repairs (21), per-path Cloud Armor rules (22), site security headers on the backend bucket (23), the static bucket read for those headers (24), the quality-audit runner (25), the site-import crawler (26), the build carrier (27), the upgrader's actAs on the staging gateway (28)", () => {
24
+ expect(INFRA_CONTRACT_VERSION).toBe(28);
25
25
  expect(INFRA_CONTRACT_STEPS[27]).toContain("#1574");
26
+ expect(INFRA_CONTRACT_STEPS[28]).toContain("#1596");
26
27
  expect(INFRA_CONTRACT_STEPS[26]).toContain("#1360");
27
28
  expect(INFRA_CONTRACT_STEPS[25]).toContain("#1359");
28
29
  expect(INFRA_CONTRACT_STEPS[24]).toContain("static bucket");
@@ -57,6 +58,6 @@ describe("infrastructure contract steps", () => {
57
58
  });
58
59
 
59
60
  it("names a version a newer release added by number", () => {
60
- expect(infraStepsText(27, 28)).toBe("infrastructure step 28 (see that release's notes)");
61
+ expect(infraStepsText(28, 29)).toBe("infrastructure step 29 (see that release's notes)");
61
62
  });
62
63
  });
@@ -22,7 +22,7 @@
22
22
  * whose app-roll references infrastructure an install does not have yet fails
23
23
  * at roll time, after migrations ran.
24
24
  */
25
- export const INFRA_CONTRACT_VERSION = 27;
25
+ export const INFRA_CONTRACT_VERSION = 28;
26
26
 
27
27
  // History (why each bump happened — an install below a number needs the
28
28
  // converge that introduced it):
@@ -224,6 +224,13 @@ export const INFRA_CONTRACT_VERSION = 27;
224
224
  // the admin. The new admin starts every crawl on that job and the
225
225
  // app-roll moves its image, so an in-cloud upgrader must not roll an
226
226
  // install onto it before it exists.
227
+ // 28 — #1596: the upgrader's actAs on the staging gateway's account. The
228
+ // app-roll rolls the staging gateway since v0.12.0 (#1330), but the
229
+ // setup never granted it, so every in-product app-roll on an install
230
+ // with a staging gateway failed at that service and rolled back. No
231
+ // new resource: the bump makes every install take its next release
232
+ // through the converge job, which runs the setup that now grants it,
233
+ // so app-roll updates work again after that one converge.
227
234
  // 27 — #1574: the build carrier (reporting-job-setup.ts), the job whose one
228
235
  // report holds the admin request a Stage, Publish live or production
229
236
  // build runs in when nobody else waits for it (an agent's Stage, a
@@ -279,6 +286,7 @@ export const INFRA_CONTRACT_STEPS: Readonly<Record<number, string>> = {
279
286
  25: "the quality-audit runner: a job of its own that runs each Stage's quality audit and reports the result to the admin, its service account and grants (#1359)",
280
287
  26: "the site-import crawler: a job of its own that crawls each site import and reports every page to the admin, its service account and grants (#1360)",
281
288
  27: "the build carrier: a job of its own that holds the request a Stage, Publish live or production build runs in when nobody else waits for it, its service account and grants (#1574)",
289
+ 28: "the upgrader's right to run the staging gateway as its service account, so updates from Settings → Updates roll every service (#1596)",
282
290
  };
283
291
 
284
292
  /**
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { describe, expect, it } from "bun:test";
11
11
  import type { HttpFetch } from "./runtime-secrets.js";
12
+ import { ROLL_ORDER, rollServiceAccount } from "./upgrade/app-roll.js";
12
13
  import {
13
14
  type IamResource,
14
15
  type IamTester,
@@ -29,6 +30,7 @@ import {
29
30
  UPGRADER_PROJECT_ROLES,
30
31
  UPGRADER_RUN_ROLE,
31
32
  UPGRADER_SQL_BACKUP_ROLE,
33
+ upgraderAccountGrants,
32
34
  } from "./upgrader-setup.js";
33
35
 
34
36
  const TARGET = { projectId: "acme", region: "europe-west1", env: "production" };
@@ -64,49 +66,16 @@ function setupGrants(): Map<string, Set<string>> {
64
66
  // (no run.developer: it would hold runWithOverrides on the provisioner's jobs).
65
67
  for (const perm of UPGRADER_RUN_ROLE.permissions) project.add(perm);
66
68
  const bucketList = new Set(UPGRADER_OPS_LIST_ROLE.permissions);
67
- return new Map([
69
+ // #1596 — the per-account grants come from upgrader-setup.ts itself, not
70
+ // from a copy here: a copy missed the staging gateway exactly as the setup
71
+ // did, so the "fresh setup passes" check below passed while every app-roll
72
+ // on an install with a staging gateway failed.
73
+ const accounts = upgraderAccountGrants(p, TARGET.env).map(
74
+ (g) => [`projects/${p}/serviceAccounts/${g.account}`, of(g.role)] as const,
75
+ );
76
+ return new Map<string, Set<string>>([
68
77
  [`projects/${p}`, project],
69
- [
70
- `projects/${p}/serviceAccounts/caelo-production-run-sa@${p}.iam.gserviceaccount.com`,
71
- of("roles/iam.serviceAccountUser"),
72
- ],
73
- [
74
- `projects/${p}/serviceAccounts/caelo-production-gateway-sa@${p}.iam.gserviceaccount.com`,
75
- of("roles/iam.serviceAccountUser"),
76
- ],
77
- // #1328 — the MCP-Auth-Proxy's revisions run as its own account.
78
- [
79
- `projects/${p}/serviceAccounts/caelo-production-mcp-proxy-sa@${p}.iam.gserviceaccount.com`,
80
- of("roles/iam.serviceAccountUser"),
81
- ],
82
- [
83
- `projects/${p}/serviceAccounts/caelo-production-upgrader@${p}.iam.gserviceaccount.com`,
84
- of("roles/iam.serviceAccountUser"),
85
- ],
86
- [
87
- `projects/${p}/serviceAccounts/caelo-mcp@${p}.iam.gserviceaccount.com`,
88
- of("roles/iam.serviceAccountTokenCreator"),
89
- ],
90
- [
91
- `projects/${p}/serviceAccounts/caelo-production-audit@${p}.iam.gserviceaccount.com`,
92
- of("roles/iam.serviceAccountUser"),
93
- ],
94
- [
95
- `projects/${p}/serviceAccounts/caelo-production-capture@${p}.iam.gserviceaccount.com`,
96
- of("roles/iam.serviceAccountUser"),
97
- ],
98
- [
99
- `projects/${p}/serviceAccounts/caelo-production-audit-run@${p}.iam.gserviceaccount.com`,
100
- of("roles/iam.serviceAccountUser"),
101
- ],
102
- [
103
- `projects/${p}/serviceAccounts/caelo-production-import@${p}.iam.gserviceaccount.com`,
104
- of("roles/iam.serviceAccountUser"),
105
- ],
106
- [
107
- `projects/${p}/serviceAccounts/caelo-production-build@${p}.iam.gserviceaccount.com`,
108
- of("roles/iam.serviceAccountUser"),
109
- ],
78
+ ...accounts,
110
79
  // The project-level caeloUpgraderRun reaches the job too.
111
80
  [`projects/${p}/locations/europe-west1/jobs/caelo-production-upgrader`, project],
112
81
  [`gs://${p}-caelo-ops`, bucketList],
@@ -258,6 +227,44 @@ describe("upgraderAccessChecks", () => {
258
227
  expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain("MCP-Auth-Proxy");
259
228
  });
260
229
 
230
+ it("#1596: the staging gateway's account is checked, since every app-roll rolls the staging gateway", async () => {
231
+ const stagingSa =
232
+ "projects/acme/serviceAccounts/caelo-production-stg-gw-sa@acme.iam.gserviceaccount.com";
233
+ const grants = setupGrants();
234
+ grants.delete(stagingSa);
235
+ const r = await runIamPreflight(upgraderAccessChecks(TARGET), tester(grants));
236
+ expect(r.kind).toBe("missing");
237
+ if (r.kind !== "missing") return;
238
+ expect(r.missing.map((m) => [resourceName(m.check.resource), m.missing])).toEqual([
239
+ [stagingSa, ["iam.serviceAccounts.actAs"]],
240
+ ]);
241
+ expect(preflightMissingReason(r.missing, UPGRADER_PREFLIGHT_VOICE)).toContain(
242
+ "staging gateway",
243
+ );
244
+ });
245
+
246
+ it("#1596: every service the app-roll rolls runs as an account setup grants actAs on and the self-check checks", () => {
247
+ const granted = new Set(
248
+ upgraderAccountGrants(TARGET.projectId, TARGET.env)
249
+ .filter((g) => g.role === "roles/iam.serviceAccountUser")
250
+ .map((g) => g.account),
251
+ );
252
+ const checked = new Set(
253
+ upgraderAccessChecks(TARGET)
254
+ .filter(
255
+ (c) =>
256
+ c.resource.kind === "service-account" &&
257
+ c.permissions.includes("iam.serviceAccounts.actAs"),
258
+ )
259
+ .map((c) => (c.resource.kind === "service-account" ? c.resource.email : "")),
260
+ );
261
+ for (const slug of ROLL_ORDER) {
262
+ const account = rollServiceAccount(slug, TARGET.projectId, TARGET.env);
263
+ expect({ slug, granted: granted.has(account) }).toEqual({ slug, granted: true });
264
+ expect({ slug, checked: checked.has(account) }).toEqual({ slug, checked: true });
265
+ }
266
+ });
267
+
261
268
  it("never needs a permission only a forbidden role would give (no compute, no IAM admin)", () => {
262
269
  const all = upgraderAccessChecks(TARGET).flatMap((c) => c.permissions);
263
270
  for (const p of all) {
@@ -60,6 +60,7 @@ import {
60
60
  mcpAuthProxyServiceAccountEmail,
61
61
  mcpIapServiceAccountEmail,
62
62
  runServiceAccountEmail,
63
+ stagingGatewayServiceAccountEmail,
63
64
  upgraderJobName,
64
65
  upgraderServiceAccountEmail,
65
66
  } from "./gcp-names.js";
@@ -230,6 +231,13 @@ export function upgraderAccessChecks(target: {
230
231
  resource: sa(gatewayServiceAccountEmail(projectId, env)),
231
232
  permissions: ["iam.serviceAccounts.actAs"],
232
233
  },
234
+ {
235
+ // #1596 — rolled since v0.12.0 (#1330) but never checked, so a run
236
+ // without the grant failed halfway through the roll instead of here.
237
+ need: "run the staging gateway as its service account",
238
+ resource: sa(stagingGatewayServiceAccountEmail(projectId, env)),
239
+ permissions: ["iam.serviceAccounts.actAs"],
240
+ },
233
241
  {
234
242
  need: "run the MCP-Auth-Proxy as its service account",
235
243
  resource: sa(mcpAuthProxyServiceAccountEmail(projectId, env)),
@@ -524,6 +524,7 @@ describe("runUpgraderJob", () => {
524
524
  "iam projects/acme/serviceAccounts/caelo-production-import@acme.iam.gserviceaccount.com",
525
525
  "iam projects/acme/serviceAccounts/caelo-production-mcp-proxy-sa@acme.iam.gserviceaccount.com",
526
526
  "iam projects/acme/serviceAccounts/caelo-production-run-sa@acme.iam.gserviceaccount.com",
527
+ "iam projects/acme/serviceAccounts/caelo-production-stg-gw-sa@acme.iam.gserviceaccount.com",
527
528
  "iam projects/acme/serviceAccounts/caelo-production-upgrader@acme.iam.gserviceaccount.com",
528
529
  "iam projects/caelo-website/locations/europe-west1/repositories/caelo-cms-images",
529
530
  ].sort(),
@@ -81,6 +81,8 @@ describe("ensureUpgraderJob", () => {
81
81
  "projects add-iam-policy-binding acme → roles/logging.logWriter",
82
82
  "projects add-iam-policy-binding acme → projects/acme/roles/caeloUpgraderSqlBackup",
83
83
  "iam service-accounts add-iam-policy-binding caelo-production-run-sa@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
84
+ // #1596 — the app-roll rolls the staging gateway, whose revisions run as it.
85
+ "iam service-accounts add-iam-policy-binding caelo-production-stg-gw-sa@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
84
86
  "iam service-accounts add-iam-policy-binding caelo-production-gateway-sa@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
85
87
  // #1328 — the MCP-Auth-Proxy's revisions run as its own account.
86
88
  "iam service-accounts add-iam-policy-binding caelo-production-mcp-proxy-sa@acme.iam.gserviceaccount.com → roles/iam.serviceAccountUser",
@@ -30,14 +30,15 @@
30
30
  * PULUMI_*) and so act as the provisioner (#883 review). The custom role
31
31
  * has no `runWithOverrides` and no `*.setIamPolicy`. Updating another
32
32
  * job (the converge job's image, say) additionally needs `actAs` on its
33
- * service account, which the upgrader holds only on the admin, gateway,
34
- * MCP-Auth-Proxy and its own. A grant of `roles/run.developer` left by an earlier
33
+ * service account, which the upgrader holds only on the accounts
34
+ * `upgraderAccountGrants` lists. A grant of `roles/run.developer` left by an earlier
35
35
  * setup is removed.
36
- * - `roles/iam.serviceAccountUser` on exactly the admin's, the
37
- * gateway's and the MCP-Auth-Proxy's (#1328) runtime service accounts (a revision runs as them), on
38
- * itself (its own job) and on the quality-audit and capture jobs'
39
- * accounts (the app-roll moves those jobs' images, #875, #1217) — not
40
- * on the project.
36
+ * - `roles/iam.serviceAccountUser` on exactly the runtime accounts of the
37
+ * services the app-roll rolls (admin, gateway, staging gateway #1596,
38
+ * MCP-Auth-Proxy #1328: a revision runs as them), on itself (its own job)
39
+ * and on the accounts of the jobs the app-roll moves onto the new image
40
+ * (quality audit, capture, audit runner, crawler, build carrier) — not
41
+ * on the project (`upgraderAccountGrants`).
41
42
  * - the custom role `caeloUpgraderSqlBackup`: create/read Cloud SQL
42
43
  * backups and read the instance — no restore, no instance changes.
43
44
  * - `roles/cloudsql.instanceUser` + a Cloud SQL IAM database user that
@@ -88,6 +89,7 @@ import {
88
89
  mcpAuthProxyServiceAccountEmail,
89
90
  mcpIapServiceAccountEmail,
90
91
  runServiceAccountEmail,
92
+ stagingGatewayServiceAccountEmail,
91
93
  upgraderJobName,
92
94
  upgraderServiceAccountEmail,
93
95
  upgraderServiceAccountId,
@@ -236,6 +238,82 @@ export function installStateCondition(bucket: string): string {
236
238
  return `expression=resource.name.startsWith("projects/_/buckets/${bucket}/objects/${OPS_INSTALL_PREFIX}/"),title=caelo-upgrader-install-state,description=Only the install metadata under ${OPS_INSTALL_PREFIX}/`;
237
239
  }
238
240
 
241
+ /** One grant the upgrader holds on a single service account. */
242
+ export interface UpgraderAccountGrant {
243
+ readonly account: string;
244
+ readonly role: string;
245
+ readonly why: string;
246
+ }
247
+
248
+ /**
249
+ * The upgrader's grants on single service accounts: `actAs` on the account
250
+ * of every service the app-roll rolls and of every job it moves onto a new
251
+ * image (a revision or execution runs as that account), on its own job's
252
+ * account, and token creation on caelo-mcp for the health check.
253
+ *
254
+ * #1596 — the staging gateway (#1330) was rolled since v0.12.0 but missing
255
+ * here, so every in-product app-roll on an install with a staging gateway
256
+ * failed at that service and rolled back. upgrader-iam-preflight.test.ts
257
+ * pins this list to `ROLL_ORDER`, so a new rolled service cannot be left out
258
+ * again.
259
+ */
260
+ export function upgraderAccountGrants(projectId: string, env: string): UpgraderAccountGrant[] {
261
+ const sa = upgraderServiceAccountEmail(projectId, env);
262
+ return [
263
+ {
264
+ account: runServiceAccountEmail(projectId, env),
265
+ role: "roles/iam.serviceAccountUser",
266
+ why: "admin revisions + the migration job run as it",
267
+ },
268
+ {
269
+ account: gatewayServiceAccountEmail(projectId, env),
270
+ role: "roles/iam.serviceAccountUser",
271
+ why: "gateway revisions run as it",
272
+ },
273
+ {
274
+ account: stagingGatewayServiceAccountEmail(projectId, env),
275
+ role: "roles/iam.serviceAccountUser",
276
+ why: "staging gateway revisions run as it (#1330, #1596)",
277
+ },
278
+ {
279
+ account: mcpAuthProxyServiceAccountEmail(projectId, env),
280
+ role: "roles/iam.serviceAccountUser",
281
+ why: "MCP-Auth-Proxy revisions run as it (#1328)",
282
+ },
283
+ { account: sa, role: "roles/iam.serviceAccountUser", why: "the job updates its own image" },
284
+ {
285
+ account: auditServiceAccountEmail(projectId, env),
286
+ role: "roles/iam.serviceAccountUser",
287
+ why: "the app-roll moves the quality-audit job, which runs as it, onto the new image",
288
+ },
289
+ {
290
+ account: captureServiceAccountEmail(projectId, env),
291
+ role: "roles/iam.serviceAccountUser",
292
+ why: "the app-roll moves the capture job, which runs as it, onto the new image",
293
+ },
294
+ {
295
+ account: auditRunnerServiceAccountEmail(projectId, env),
296
+ role: "roles/iam.serviceAccountUser",
297
+ why: "the app-roll moves the quality-audit runner, which runs as it, onto the new image",
298
+ },
299
+ {
300
+ account: importCrawlServiceAccountEmail(projectId, env),
301
+ role: "roles/iam.serviceAccountUser",
302
+ why: "the app-roll moves the site-import crawler, which runs as it, onto the new image",
303
+ },
304
+ {
305
+ account: buildCarrierServiceAccountEmail(projectId, env),
306
+ role: "roles/iam.serviceAccountUser",
307
+ why: "the app-roll moves the build carrier, which runs as it, onto the new image",
308
+ },
309
+ {
310
+ account: mcpIapServiceAccountEmail(projectId),
311
+ role: "roles/iam.serviceAccountTokenCreator",
312
+ why: "the health check signs its IAP credential as caelo-mcp",
313
+ },
314
+ ];
315
+ }
316
+
239
317
  /** Ensure the upgrader job and everything it needs. Never throws for a gcloud failure. */
240
318
  export async function ensureUpgraderJob(
241
319
  target: UpgraderSetupTarget,
@@ -363,54 +441,7 @@ export async function ensureUpgraderJob(
363
441
  }
364
442
 
365
443
  // 4. Resource-level grants on single service accounts.
366
- const onAccounts: { account: string; role: string; why: string }[] = [
367
- {
368
- account: runServiceAccountEmail(projectId, env),
369
- role: "roles/iam.serviceAccountUser",
370
- why: "admin revisions + the migration job run as it",
371
- },
372
- {
373
- account: gatewayServiceAccountEmail(projectId, env),
374
- role: "roles/iam.serviceAccountUser",
375
- why: "gateway revisions run as it",
376
- },
377
- {
378
- account: mcpAuthProxyServiceAccountEmail(projectId, env),
379
- role: "roles/iam.serviceAccountUser",
380
- why: "MCP-Auth-Proxy revisions run as it (#1328)",
381
- },
382
- { account: sa, role: "roles/iam.serviceAccountUser", why: "the job updates its own image" },
383
- {
384
- account: auditServiceAccountEmail(projectId, env),
385
- role: "roles/iam.serviceAccountUser",
386
- why: "the app-roll moves the quality-audit job, which runs as it, onto the new image",
387
- },
388
- {
389
- account: captureServiceAccountEmail(projectId, env),
390
- role: "roles/iam.serviceAccountUser",
391
- why: "the app-roll moves the capture job, which runs as it, onto the new image",
392
- },
393
- {
394
- account: auditRunnerServiceAccountEmail(projectId, env),
395
- role: "roles/iam.serviceAccountUser",
396
- why: "the app-roll moves the quality-audit runner, which runs as it, onto the new image",
397
- },
398
- {
399
- account: importCrawlServiceAccountEmail(projectId, env),
400
- role: "roles/iam.serviceAccountUser",
401
- why: "the app-roll moves the site-import crawler, which runs as it, onto the new image",
402
- },
403
- {
404
- account: buildCarrierServiceAccountEmail(projectId, env),
405
- role: "roles/iam.serviceAccountUser",
406
- why: "the app-roll moves the build carrier, which runs as it, onto the new image",
407
- },
408
- {
409
- account: mcpIapServiceAccountEmail(projectId),
410
- role: "roles/iam.serviceAccountTokenCreator",
411
- why: "the health check signs its IAP credential as caelo-mcp",
412
- },
413
- ];
444
+ const onAccounts = upgraderAccountGrants(projectId, env);
414
445
  for (const g of onAccounts) {
415
446
  const r = await retry([
416
447
  "iam",
package/src/wizard.ts CHANGED
@@ -91,6 +91,12 @@ export interface WizardOptions {
91
91
  version?: string;
92
92
  /** #1558 — `--accept-release-candidate`: confirms a release candidate without a prompt. */
93
93
  acceptReleaseCandidate?: boolean;
94
+ /**
95
+ * #1580 — `--billing-account` (already parsed): the billing account a new
96
+ * GCP project is linked to; skips the picker. Needed with `nonInteractive`
97
+ * when the signed-in account has several open billing accounts.
98
+ */
99
+ billingAccountId?: string;
94
100
  }
95
101
 
96
102
  export async function runWizard(opts: WizardOptions = {}): Promise<void> {
@@ -129,6 +135,7 @@ export async function runWizard(opts: WizardOptions = {}): Promise<void> {
129
135
  const prep = await prepareJobModeInstall({
130
136
  ...(opts.projectId ? { projectId: opts.projectId } : {}),
131
137
  ...(opts.version ? { version: opts.version } : {}),
138
+ ...(opts.billingAccountId ? { billingAccountId: opts.billingAccountId } : {}),
132
139
  });
133
140
  if (prep.kind === "handled") {
134
141
  outro(bold("Done."));
@@ -232,6 +239,7 @@ export async function runWizard(opts: WizardOptions = {}): Promise<void> {
232
239
  ...(opts.version ? { version: opts.version } : {}),
233
240
  ...(opts.acceptReleaseCandidate ? { acceptReleaseCandidate: true } : {}),
234
241
  };
242
+ const billing = opts.billingAccountId ? { billingAccountId: opts.billingAccountId } : {};
235
243
  switch (provider) {
236
244
  case "gcp":
237
245
  await runGcpWizard({
@@ -243,6 +251,7 @@ export async function runWizard(opts: WizardOptions = {}): Promise<void> {
243
251
  ...(opts.region ? { region: opts.region } : {}),
244
252
  runMode,
245
253
  ...release,
254
+ ...billing,
246
255
  });
247
256
  break;
248
257
  case "gcp-firebase":
@@ -255,6 +264,7 @@ export async function runWizard(opts: WizardOptions = {}): Promise<void> {
255
264
  ...(opts.region ? { region: opts.region } : {}),
256
265
  runMode,
257
266
  ...release,
267
+ ...billing,
258
268
  });
259
269
  break;
260
270
  case "self-hosted":