@caelo-cms/provisioning 0.11.20 → 0.11.21

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 (57) hide show
  1. package/dist/admin-internal-google.d.ts +13 -1
  2. package/dist/admin-internal-google.d.ts.map +1 -1
  3. package/dist/admin-internal-google.js +47 -0
  4. package/dist/admin-internal-google.js.map +1 -1
  5. package/dist/agent/command.d.ts +1 -1
  6. package/dist/cli-routing.d.ts.map +1 -1
  7. package/dist/cli-routing.js +2 -2
  8. package/dist/cli-routing.js.map +1 -1
  9. package/dist/cli.js +5 -0
  10. package/dist/cli.js.map +1 -1
  11. package/dist/converge-checkpoint.d.ts +6 -0
  12. package/dist/converge-checkpoint.d.ts.map +1 -1
  13. package/dist/dns/manual.d.ts +5 -1
  14. package/dist/dns/manual.d.ts.map +1 -1
  15. package/dist/dns/manual.js +2 -1
  16. package/dist/dns/manual.js.map +1 -1
  17. package/dist/install-job-runner.d.ts.map +1 -1
  18. package/dist/install-job-runner.js +4 -3
  19. package/dist/install-job-runner.js.map +1 -1
  20. package/dist/install-job.d.ts +25 -1
  21. package/dist/install-job.d.ts.map +1 -1
  22. package/dist/install-job.js +72 -3
  23. package/dist/install-job.js.map +1 -1
  24. package/dist/operator-access.d.ts +7 -2
  25. package/dist/operator-access.d.ts.map +1 -1
  26. package/dist/operator-access.js +37 -6
  27. package/dist/operator-access.js.map +1 -1
  28. package/dist/project-status.d.ts +95 -0
  29. package/dist/project-status.d.ts.map +1 -0
  30. package/dist/project-status.js +213 -0
  31. package/dist/project-status.js.map +1 -0
  32. package/dist/state-attach.d.ts +17 -0
  33. package/dist/state-attach.d.ts.map +1 -1
  34. package/dist/state-attach.js +27 -9
  35. package/dist/state-attach.js.map +1 -1
  36. package/dist/wizards/gcp-install-job.d.ts +27 -4
  37. package/dist/wizards/gcp-install-job.d.ts.map +1 -1
  38. package/dist/wizards/gcp-install-job.js +62 -32
  39. package/dist/wizards/gcp-install-job.js.map +1 -1
  40. package/dist/wizards/gcp.d.ts +3 -0
  41. package/dist/wizards/gcp.d.ts.map +1 -1
  42. package/dist/wizards/gcp.js +10 -4
  43. package/dist/wizards/gcp.js.map +1 -1
  44. package/package.json +2 -2
  45. package/src/admin-internal-google.ts +48 -0
  46. package/src/cli-routing.ts +3 -2
  47. package/src/cli.ts +5 -0
  48. package/src/dns/manual.ts +4 -1
  49. package/src/install-job-runner.ts +4 -2
  50. package/src/install-job.ts +86 -4
  51. package/src/operator-access.test.ts +43 -0
  52. package/src/operator-access.ts +38 -6
  53. package/src/project-status.test.ts +462 -0
  54. package/src/project-status.ts +306 -0
  55. package/src/state-attach.ts +46 -16
  56. package/src/wizards/gcp-install-job.ts +91 -46
  57. package/src/wizards/gcp.ts +14 -7
@@ -0,0 +1,213 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * `cms-provision status --project <id>` (#822): where an install stands, on
4
+ * any machine. The install job keeps running after the Cloud Shell tab is
5
+ * gone, and a reset Cloud Shell has no `~/.caelo-*` left, so this command
6
+ * needs nothing but a signed-in gcloud identity: it reads the project
7
+ * (install.json, install-job.json and progress.json in the ops bucket, the
8
+ * Owner setup link in Secret Manager) and writes nothing, here or there.
9
+ *
10
+ * The setup link is a secret (#656). It goes to a terminal only: with stdout
11
+ * piped or redirected it stays unprinted, so it can't land in a CI log or a
12
+ * file. Once Owner setup is done the command says so instead of showing a
13
+ * used link.
14
+ */
15
+ import { log } from "@clack/prompts";
16
+ import { bold, cyan, dim, green, red, yellow } from "kleur/colors";
17
+ import { z } from "zod";
18
+ import { readOwnerSetupState } from "./admin-internal-google.js";
19
+ import { formatDnsRecordGroups, groupDnsRecords, } from "./dns/groups.js";
20
+ import { checkRecord } from "./dns/manual.js";
21
+ import { checkGcloudAuth, gcloud } from "./gcloud.js";
22
+ import { INSTALL_SETUP_LINK_SECRET, isGcpProjectId, readRecordedStackOutputs, readSetupLink, recordedDnsRecords, } from "./install-job.js";
23
+ import { readProjectInstall } from "./state-attach.js";
24
+ import { realSyncGcloud } from "./state-store.js";
25
+ import { installerCommand, installJobViewLines, readInstallJobView, } from "./wizards/gcp-install-job.js";
26
+ /** The parts of install.json this command reads. */
27
+ const InstallRecordSchema = z.object({
28
+ installId: z.string().min(1),
29
+ provider: z.enum(["gcp", "gcp-firebase"]),
30
+ domain: z.string().min(1),
31
+ ownerEmail: z.string().min(1),
32
+ projectId: z.string().min(1),
33
+ region: z.string().min(1).nullable().default(null),
34
+ });
35
+ /** The admin's origin from the stack's outputs; null before the stack ran. */
36
+ export function adminUrlFromOutputs(provider, outputs) {
37
+ // gcp-firebase binds admin.<domain> only on request; the setup link and
38
+ // the install's summary use the Cloud Run URL there (wizards/gcp.ts).
39
+ if (provider === "gcp-firebase") {
40
+ const url = outputs.adminCloudRunUrlOut;
41
+ return typeof url === "string" && url !== "" ? url : null;
42
+ }
43
+ const host = outputs.adminDomainOut;
44
+ return typeof host === "string" && host !== "" ? `https://${host}` : null;
45
+ }
46
+ /**
47
+ * Split `records` by what still has to happen: a record public DNS already
48
+ * answers is dropped, the rest fall into {@link groupDnsRecords}'s two groups.
49
+ */
50
+ export async function dnsRecordsToSet(records, domain, resolves) {
51
+ const unique = [
52
+ ...new Map(records.map((r) => [`${r.type}:${r.hostname}:${r.value}`, r])).values(),
53
+ ];
54
+ const answered = await Promise.all(unique.map(resolves));
55
+ const open = unique.filter((_, i) => !answered[i]);
56
+ return { ...groupDnsRecords(open, domain), total: unique.length };
57
+ }
58
+ /** Where {@link readOwnerSetupState} reaches the admin; null without a recorded region. */
59
+ function adminTarget(install) {
60
+ const { provider, projectId, domain, region } = install;
61
+ if (provider === "gcp")
62
+ return { provider, projectId, domain };
63
+ return region ? { provider, projectId, region } : null;
64
+ }
65
+ async function readOwnerSetup(args, deps) {
66
+ const unfinished = args.job ? args.job.decision.kind !== "done" : !args.provisioned;
67
+ if (unfinished || args.adminUrl === null)
68
+ return { kind: "not-yet" };
69
+ let link;
70
+ try {
71
+ link = await readSetupLink(deps.run, args.install.projectId);
72
+ }
73
+ catch (e) {
74
+ return { kind: "error", message: e instanceof Error ? e.message : String(e) };
75
+ }
76
+ if (link === null)
77
+ return { kind: "no-link" };
78
+ const target = adminTarget(args.install);
79
+ const state = target
80
+ ? await deps.ownerSetupState(target)
81
+ : { ok: false, error: "install.json records no region" };
82
+ if (state.ok && state.value === "done")
83
+ return { kind: "done" };
84
+ if (!deps.isTerminal)
85
+ return { kind: "withheld" };
86
+ return { kind: "link", link, unverified: state.ok ? null : state.error };
87
+ }
88
+ /**
89
+ * Read where the install in `projectId` stands from the project alone.
90
+ *
91
+ * @throws when a read fails, with what to do about it
92
+ */
93
+ export async function readProjectStatus(projectId, deps) {
94
+ const record = readProjectInstall(projectId, deps.syncRun);
95
+ if (!record.ok)
96
+ throw new Error(record.error);
97
+ const parsed = InstallRecordSchema.safeParse(JSON.parse(record.text));
98
+ if (!parsed.success) {
99
+ throw new Error(`install.json of ${projectId} is not a Google Cloud install this CLI understands (${parsed.error.message}). Run this command with the CLI of the release the install runs.`);
100
+ }
101
+ const install = parsed.data;
102
+ const job = await readInstallJobView(install, deps);
103
+ const outputs = readRecordedStackOutputs(projectId, deps.syncRun);
104
+ const provisioned = Object.keys(outputs).length > 0;
105
+ const adminUrl = adminUrlFromOutputs(install.provider, outputs);
106
+ const dns = await dnsRecordsToSet([...recordedDnsRecords(outputs), ...(job?.status.dnsRecords ?? [])], install.domain, deps.resolves);
107
+ const owner = await readOwnerSetup({ install, adminUrl, job, provisioned }, deps);
108
+ return { install, job, provisioned, adminUrl, dns, owner };
109
+ }
110
+ function jobLines(s) {
111
+ if (s.job)
112
+ return installJobViewLines(s.job, s.install);
113
+ return s.provisioned
114
+ ? ["Install job: none. This install ran from a terminal, not through the job."]
115
+ : [`Install job: not started. Start or resume it: ${installerCommand(s.install)}`];
116
+ }
117
+ function dnsLines(s) {
118
+ const { dns, install } = s;
119
+ if (dns.total === 0) {
120
+ return ["DNS: not known yet; the install reports its records once its resources exist."];
121
+ }
122
+ const lines = dns.setNow.length + dns.atGoLive.length === 0
123
+ ? [`DNS: ${green(`all set (${dns.total} of ${dns.total}).`)}`]
124
+ : [
125
+ `DNS records still to set for ${bold(install.domain)}:`,
126
+ ...formatDnsRecordGroups(dns, install.domain).map((l) => ` ${l}`),
127
+ ];
128
+ // The staging host's records reach the status document only through the
129
+ // job; a terminal install or an older job recorded none there.
130
+ if (!s.job?.status.dnsRecords) {
131
+ lines.push(dim(" The staging host's records are under Settings → Updates in the admin."));
132
+ }
133
+ return lines;
134
+ }
135
+ function ownerLines(s) {
136
+ const { owner, install, adminUrl } = s;
137
+ const command = installerCommand(install);
138
+ switch (owner.kind) {
139
+ case "not-yet":
140
+ return ["Owner setup: the link appears here when the install has finished."];
141
+ case "done":
142
+ return [`Owner setup: ${green("done.")} Sign in at ${cyan(adminUrl ?? "")}`];
143
+ case "withheld":
144
+ return [
145
+ `Owner setup: ${yellow("a link is stored, but it is a secret and only goes to a terminal.")} Run this command in your own terminal, without a pipe or redirect.`,
146
+ ];
147
+ case "no-link":
148
+ return [
149
+ `Owner setup: no link is stored in this project (${INSTALL_SETUP_LINK_SECRET}). If Owner setup is done, sign in at ${cyan(adminUrl ?? "")}`,
150
+ ` If it is not, this finishes the install and stores a link: ${command}`,
151
+ ];
152
+ case "error":
153
+ return [`Owner setup: ${red(owner.message)}`];
154
+ case "link":
155
+ return [
156
+ `Owner setup: open this link in your browser, signed in as ${install.ownerEmail}. Do not share it.`,
157
+ ` ${bold(cyan(owner.link))}`,
158
+ ...(owner.unverified === null
159
+ ? []
160
+ : [
161
+ yellow(` Could not check whether it was already used (${owner.unverified}). A used link just opens the sign-in page.`),
162
+ ]),
163
+ ];
164
+ }
165
+ }
166
+ /** {@link ProjectStatus} as text. Holds the setup link only for {@link OwnerSetup} `link`. */
167
+ export function projectStatusLines(s) {
168
+ return [
169
+ `Install: ${bold(s.install.installId)} ${dim(`(${s.install.provider})`)}`,
170
+ `Domain: ${bold(s.install.domain)}`,
171
+ `Project: ${bold(s.install.projectId)}`,
172
+ ...jobLines(s),
173
+ `Admin: ${s.adminUrl ? cyan(s.adminUrl) : "not known yet"}`,
174
+ ...dnsLines(s),
175
+ ...ownerLines(s),
176
+ ];
177
+ }
178
+ /** What to tell the operator about a failure of the command. */
179
+ export function projectStatusFailure(e) {
180
+ if (e?.code === "ENOENT") {
181
+ return "gcloud is not installed on this machine. Install the Google Cloud CLI (https://cloud.google.com/sdk/docs/install) or use Cloud Shell, run `gcloud auth login`, then run this command again.";
182
+ }
183
+ return e instanceof Error ? e.message : String(e);
184
+ }
185
+ /** `status --project <id>`: print where the install stands; exit 1 when part of it can't be read. */
186
+ export async function projectStatusCommand(argv) {
187
+ const projectId = argv[argv.indexOf("--project") + 1] ?? "";
188
+ if (!isGcpProjectId(projectId) || argv.includes("--install")) {
189
+ console.error("Usage: cms-provision status --project <gcp-project-id>");
190
+ process.exit(2);
191
+ }
192
+ try {
193
+ const auth = await checkGcloudAuth();
194
+ if (!auth.ok)
195
+ throw new Error(auth.error);
196
+ const status = await readProjectStatus(projectId, {
197
+ run: gcloud,
198
+ syncRun: realSyncGcloud,
199
+ resolves: checkRecord,
200
+ ownerSetupState: (target) => readOwnerSetupState(target),
201
+ isTerminal: process.stdout.isTTY === true,
202
+ });
203
+ for (const line of projectStatusLines(status))
204
+ console.log(line);
205
+ if (status.owner.kind === "error")
206
+ process.exitCode = 1;
207
+ }
208
+ catch (e) {
209
+ log.error(red(projectStatusFailure(e)));
210
+ process.exit(1);
211
+ }
212
+ }
213
+ //# sourceMappingURL=project-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-status.js","sourceRoot":"","sources":["../src/project-status.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAA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project's ops bucket, checked. */
12
+ export type ProjectInstallRecord = {
13
+ readonly ok: true;
14
+ readonly installId: string;
15
+ readonly domain: string;
16
+ /** install.json exactly as the bucket held it. */
17
+ readonly text: string;
18
+ } | {
19
+ readonly ok: false;
20
+ readonly error: string;
21
+ };
22
+ /**
23
+ * Read and check `gs://<project>-caelo-ops/install/install.json`, touching
24
+ * nothing on this machine: shared by `attach` and `status --project`, which
25
+ * has to work with no local install directory at all (#822).
26
+ */
27
+ export declare function readProjectInstall(projectId: string, run: SyncGcloud): ProjectInstallRecord;
11
28
  /**
12
29
  * Attach the install in `projectId` to this machine.
13
30
  *
@@ -1 +1 @@
1
- {"version":3,"file":"state-attach.d.ts","sourceRoot":"","sources":["../src/state-attach.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,MAAM,YAAY,GACpB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;CAC3C,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKnD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;IACJ,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C,GACA,YAAY,CAsFd"}
1
+ {"version":3,"file":"state-attach.d.ts","sourceRoot":"","sources":["../src/state-attach.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,MAAM,YAAY,GACpB;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC;CAC3C,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKnD,6DAA6D;AAC7D,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,GAAG,oBAAoB,CA0D3F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE;IACJ,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C,GACA,YAAY,CAwCd"}
@@ -17,18 +17,16 @@ import { GcsStateStore, LocalStateStore } from "./state-store.js";
17
17
  /** Install ids are `<provider>-<slug>` (install-state.ts deriveInstallId). */
18
18
  const INSTALL_ID = /^[a-z0-9][a-z0-9-]{0,80}$/;
19
19
  /**
20
- * Attach the install in `projectId` to this machine.
21
- *
22
- * @param deps.run gcloud runner (tests pass a fake bucket)
23
- * @param deps.rootFor `~/.caelo-<id>` for an install id
24
- * @param deps.hasLocalState whether a dir holds a local Pulumi stack
20
+ * Read and check `gs://<project>-caelo-ops/install/install.json`, touching
21
+ * nothing on this machine: shared by `attach` and `status --project`, which
22
+ * has to work with no local install directory at all (#822).
25
23
  */
26
- export function attachInstall(projectId, deps) {
24
+ export function readProjectInstall(projectId, run) {
27
25
  const bucket = opsBucketName(projectId);
28
26
  let text;
29
27
  try {
30
28
  // Peek: the directory to mirror into isn't known (or checked) yet.
31
- text = new GcsStateStore(bucket, "/nonexistent", deps.run).peek("install.json");
29
+ text = new GcsStateStore(bucket, "/nonexistent", run).peek("install.json");
32
30
  }
33
31
  catch (e) {
34
32
  return { ok: false, error: e instanceof Error ? e.message : String(e) };
@@ -36,7 +34,7 @@ export function attachInstall(projectId, deps) {
36
34
  if (text === null) {
37
35
  return {
38
36
  ok: false,
39
- error: `gs://${bucket} holds no install.json. If this install's state is still on the machine that installed it, run \`${selfCommand("state", "migrate")}\` there first.`,
37
+ error: `gs://${bucket} holds no install.json. Check the project id. If this install's state is still on the machine that installed it, run \`${selfCommand("state", "migrate")}\` there first.`,
40
38
  };
41
39
  }
42
40
  let remote;
@@ -72,6 +70,26 @@ export function attachInstall(projectId, deps) {
72
70
  error: `install.json in gs://${bucket} names another bucket (${backend.bucket}); refusing to attach.`,
73
71
  };
74
72
  }
73
+ return {
74
+ ok: true,
75
+ installId,
76
+ domain: typeof remote.domain === "string" ? remote.domain : installId,
77
+ text,
78
+ };
79
+ }
80
+ /**
81
+ * Attach the install in `projectId` to this machine.
82
+ *
83
+ * @param deps.run gcloud runner (tests pass a fake bucket)
84
+ * @param deps.rootFor `~/.caelo-<id>` for an install id
85
+ * @param deps.hasLocalState whether a dir holds a local Pulumi stack
86
+ */
87
+ export function attachInstall(projectId, deps) {
88
+ const bucket = opsBucketName(projectId);
89
+ const record = readProjectInstall(projectId, deps.run);
90
+ if (!record.ok)
91
+ return record;
92
+ const { installId, domain, text } = record;
75
93
  const root = deps.rootFor(installId);
76
94
  const localText = new LocalStateStore(root).read("install.json");
77
95
  // Local Pulumi state blocks the attach whether or not an install.json
@@ -105,7 +123,7 @@ export function attachInstall(projectId, deps) {
105
123
  return {
106
124
  ok: true,
107
125
  installId,
108
- domain: typeof remote.domain === "string" ? remote.domain : installId,
126
+ domain,
109
127
  status,
110
128
  };
111
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"state-attach.js","sourceRoot":"","sources":["../src/state-attach.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAmB,MAAM,kBAAkB,CAAC;AAWnF,8EAA8E;AAC9E,MAAM,UAAU,GAAG,2BAA2B,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,SAAiB,EACjB,IAIC;IAED,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,IAAmB,CAAC;IACxB,IAAI,CAAC;QACH,mEAAmE;QACnE,IAAI,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAClF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,CAAC;IACD,IAAI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SAChN,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,GAA6B,UAAU,CAAC;IAClD,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAA+B,CAAC;QAClE,MAAM,YAAY,GAAG,iBAAiB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC3D,IAAI,YAAY,EAAE,IAAI,KAAK,KAAK,IAAI,YAAY,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACnE,MAAM,GAAG,WAAW,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG,IAAI,wDAAwD,IAAI,6BAA6B;aACxG,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACzE,yEAAyE;IACzE,oEAAoE;IACpE,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAClE,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAChE,OAAO;QACL,EAAE,EAAE,IAAI;QACR,SAAS;QACT,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { GcloudRunner, Sleep } from "../gcloud-retry.js";
2
- import { type InstallJobStatus } from "../install-job.js";
2
+ import { type InstallJobDecision, type InstallJobStatus } from "../install-job.js";
3
3
  import { type InstallMetadata } from "../install-state.js";
4
4
  import { type SyncGcloud } from "../state-store.js";
5
5
  /** Side effects of the tail loop, injectable for tests. */
@@ -29,6 +29,12 @@ export declare function tailInstallJob(target: {
29
29
  region: string;
30
30
  execution: string;
31
31
  }, deps?: TailDeps): Promise<TailOutcome>;
32
+ /**
33
+ * What the terminal says before it hands the install to the job (#822): the
34
+ * tab may close, and the one command that shows where the install stands
35
+ * from any terminal.
36
+ */
37
+ export declare function handoffLines(projectId: string): string[];
32
38
  /**
33
39
  * After the bootstrap (gcp.ts, job mode): pin the release, start the job —
34
40
  * or attach to / show the one already there — and follow it.
@@ -62,10 +68,27 @@ export type JobModePreparation = {
62
68
  export declare function prepareJobModeInstall(opts: {
63
69
  projectId?: string;
64
70
  }): Promise<JobModePreparation>;
71
+ /** The command that follows or resumes the install in `meta`'s project, on any machine. */
72
+ export declare function installerCommand(meta: Pick<InstallMetadata, "provider" | "projectId">): string;
73
+ /** How the install job stands: what the bucket records and what that means. */
74
+ export interface InstallJobView {
75
+ readonly status: InstallJobStatus;
76
+ readonly decision: InstallJobDecision;
77
+ }
78
+ /**
79
+ * What the bucket records about the install job and, for a run that claims
80
+ * to be running, whether its execution still is. Null when the install
81
+ * never used the job.
82
+ */
83
+ export declare function readInstallJobView(meta: Pick<InstallMetadata, "projectId" | "region">, deps: {
84
+ run: GcloudRunner;
85
+ syncRun: SyncGcloud;
86
+ }): Promise<InstallJobView | null>;
87
+ /** {@link InstallJobView} as `status` prints it, with the command that goes on from there. */
88
+ export declare function installJobViewLines(view: InstallJobView, meta: Pick<InstallMetadata, "provider" | "projectId">): string[];
65
89
  /**
66
- * `status`'s view of the install job: what the bucket records and, for a
67
- * run that claims to be running, whether its execution still is. Empty
68
- * when the install never used the job.
90
+ * `status`'s view of the install job as text. Empty when the install never
91
+ * used the job.
69
92
  */
70
93
  export declare function installJobStatusLines(meta: InstallMetadata, deps?: {
71
94
  run: GcloudRunner;
@@ -1 +1 @@
1
- {"version":3,"file":"gcp-install-job.d.ts","sourceRoot":"","sources":["../../src/wizards/gcp-install-job.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,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,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6C9B;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,WAAW,CAAC,GAAG,MAAM,CAQ9F;AAED,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,QAAQ,CAAC,EACnD,IAAI,EAAE;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GAC/C,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAahC;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,WAAW,CAAC,GACpD,MAAM,EAAE,CAcV;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAA6C,GAC1F,OAAO,CAAC,MAAM,EAAE,CAAC,CAGnB"}
@@ -14,7 +14,7 @@ import { bold, cyan, dim, green, red, yellow } from "kleur/colors";
14
14
  import { formatDnsRecordGroups, groupDnsRecords } from "../dns/groups.js";
15
15
  import { activeAccount, gcloud } from "../gcloud.js";
16
16
  import { realSleep } from "../gcloud-retry.js";
17
- import { acquireLaunchLock, claimInstallJobStatus, decideInstallJob, describeExecution, INSTALL_CLOUDFLARE_TOKEN_SECRET, INSTALL_JOB_NAME, INSTALL_SETUP_LINK_SECRET, opsImageRef, readExecutionLogs, readInstallJobStatus, readSetupLink, startInstallJob, storeInstallSecretValue, } from "../install-job.js";
17
+ import { acquireLaunchLock, claimInstallJobStatus, decideInstallJob, describeExecution, INSTALL_CLOUDFLARE_TOKEN_SECRET, INSTALL_JOB_NAME, INSTALL_SETUP_LINK_SECRET, opsImageRef, readExecutionLogs, readInstallJobStatus, readRecordedStackOutputs, readSetupLink, recordedDnsRecords, startInstallJob, storeInstallSecretValue, } from "../install-job.js";
18
18
  import { currentMetadata, installRoot, isStepDone, readLocalMetadata, readMetadata, recordedImageDigests, recordImageDigests, } from "../install-state.js";
19
19
  import { fetchVerifiedReleaseManifest } from "../release-manifest.js";
20
20
  import { selfCommand } from "../self-command.js";
@@ -121,15 +121,30 @@ export async function tailInstallJob(target, deps = realTailDeps) {
121
121
  function logsHint(projectId, region) {
122
122
  return `gcloud run jobs executions list --job=${INSTALL_JOB_NAME} --region=${region} --project=${projectId}`;
123
123
  }
124
- /** Print that closing the tab is fine; exit 130 on Ctrl-C with the re-attach hint. */
125
- function announceDetachable(projectId, execution) {
126
- log.info([
127
- `The install runs in your project as Cloud Run job ${bold(INSTALL_JOB_NAME)} (execution ${dim(execution)}).`,
128
- dim("Closing this tab, Ctrl-C or Cloud Shell's idle timeout does not stop it. To follow it again, re-open the"),
129
- dim(`"Open in Cloud Shell" link (or re-run the same command) and pick project ${projectId}.`),
130
- ].join("\n"));
124
+ /**
125
+ * What the terminal says before it hands the install to the job (#822): the
126
+ * tab may close, and the one command that shows where the install stands
127
+ * from any terminal.
128
+ */
129
+ export function handoffLines(projectId) {
130
+ return [
131
+ bold(yellow("You may close this tab now.")),
132
+ "The install keeps running in your Google Cloud project. To see where it stands",
133
+ "(phase, DNS records, admin URL, Owner setup link), run this in any terminal",
134
+ "signed in to gcloud:",
135
+ "",
136
+ ` ${bold(cyan(selfCommand("status", "--project", projectId)))}`,
137
+ ];
138
+ }
139
+ /** Print {@link handoffLines}, highlighted. */
140
+ function announceHandoff(projectId) {
141
+ note(handoffLines(projectId).join("\n"), "The install runs on its own from here");
142
+ }
143
+ /** Name the job being followed; exit 130 on Ctrl-C with the way back. */
144
+ function announceFollowing(projectId, execution) {
145
+ log.info(`The install runs in your project as Cloud Run job ${bold(INSTALL_JOB_NAME)} (execution ${dim(execution)}).`);
131
146
  process.once("SIGINT", () => {
132
- process.stdout.write(`\nStopped following. The install keeps running in ${projectId}; re-run to attach again.\n`);
147
+ process.stdout.write(`\nStopped following. The install keeps running in ${projectId}; to see where it stands: ${selfCommand("status", "--project", projectId)}\n`);
133
148
  process.exit(130);
134
149
  });
135
150
  }
@@ -137,7 +152,7 @@ function announceDetachable(projectId, execution) {
137
152
  async function followToTheEnd(meta, execution) {
138
153
  const projectId = meta.projectId ?? "";
139
154
  const region = meta.region ?? "";
140
- announceDetachable(projectId, execution);
155
+ announceFollowing(projectId, execution);
141
156
  const outcome = await tailInstallJob({ projectId, region, execution });
142
157
  if (outcome.kind === "succeeded") {
143
158
  await showResult(meta);
@@ -165,15 +180,7 @@ async function showResult(meta) {
165
180
  // The records from the stack's outputs, as the pulumi-up step recorded
166
181
  // them — not from the log, which a re-run after the install no longer shows.
167
182
  // Uncached: this process may hold progress.json from before the job ran.
168
- const progressText = new GcsStateStore(opsBucketName(projectId), installRoot(meta.installId), realSyncGcloud).peek("progress.json");
169
- const progress = progressText
170
- ? JSON.parse(progressText)
171
- : {};
172
- const pulumiUp = progress.steps?.[`pulumi-up-${projectId}`];
173
- const outputs = pulumiUp?.outputs ?? {};
174
- const records = Array.isArray(outputs.dnsRecordsRequiredOut)
175
- ? outputs.dnsRecordsRequiredOut
176
- : [];
183
+ const records = recordedDnsRecords(readRecordedStackOutputs(projectId, realSyncGcloud));
177
184
  const dnsLines = records.length > 0
178
185
  ? [
179
186
  "",
@@ -208,6 +215,7 @@ export async function launchInstallJob(opts) {
208
215
  throw new Error(`No install.json for install '${installId}'.`);
209
216
  const decision = await decide(gcloud, realSyncGcloud, { projectId, region });
210
217
  if (decision.kind === "attach") {
218
+ announceHandoff(projectId);
211
219
  await followToTheEnd(meta, decision.status.execution);
212
220
  return;
213
221
  }
@@ -257,8 +265,10 @@ export async function launchInstallJob(opts) {
257
265
  const now = await decide(gcloud, realSyncGcloud, { projectId, region });
258
266
  if (now.kind !== "start") {
259
267
  release();
260
- if (now.kind === "attach")
268
+ if (now.kind === "attach") {
269
+ announceHandoff(projectId);
261
270
  await followToTheEnd(meta, now.status.execution);
271
+ }
262
272
  else
263
273
  await showResult(meta);
264
274
  return;
@@ -276,6 +286,7 @@ export async function launchInstallJob(opts) {
276
286
  }
277
287
  log.info(`DNS: the job sets the records through Cloudflare (token stored in Secret Manager as ${INSTALL_CLOUDFLARE_TOKEN_SECRET}).`);
278
288
  }
289
+ announceHandoff(projectId);
279
290
  const started = await startInstallJob(gcloud, {
280
291
  projectId,
281
292
  region,
@@ -356,6 +367,7 @@ export async function prepareJobModeInstall(opts) {
356
367
  return { kind: "existing", meta };
357
368
  const decision = await decide(gcloud, realSyncGcloud, { projectId, region: meta.region });
358
369
  if (decision.kind === "attach") {
370
+ announceHandoff(projectId);
359
371
  await followToTheEnd(meta, decision.status.execution);
360
372
  return { kind: "handled" };
361
373
  }
@@ -365,34 +377,52 @@ export async function prepareJobModeInstall(opts) {
365
377
  }
366
378
  return { kind: "existing", meta };
367
379
  }
380
+ /** The command that follows or resumes the install in `meta`'s project, on any machine. */
381
+ export function installerCommand(meta) {
382
+ return selfCommand("--provider", meta.provider, "--install-job", "--project-id", meta.projectId ?? "<gcp-project-id>");
383
+ }
368
384
  /**
369
- * `status`'s view of the install job: what the bucket records and, for a
370
- * run that claims to be running, whether its execution still is. Empty
371
- * when the install never used the job.
385
+ * What the bucket records about the install job and, for a run that claims
386
+ * to be running, whether its execution still is. Null when the install
387
+ * never used the job.
372
388
  */
373
- export async function installJobStatusLines(meta, deps = { run: gcloud, syncRun: realSyncGcloud }) {
389
+ export async function readInstallJobView(meta, deps) {
374
390
  if (!meta.projectId || !meta.region)
375
- return [];
391
+ return null;
376
392
  const status = readInstallJobStatus(opsBucketName(meta.projectId), deps.syncRun);
377
393
  if (!status)
378
- return [];
379
- const decision = decideInstallJob(status, status.state === "running"
394
+ return null;
395
+ const live = status.state === "running"
380
396
  ? await describeExecution(deps.run, {
381
397
  projectId: meta.projectId,
382
398
  region: meta.region,
383
399
  execution: status.execution,
384
400
  })
385
- : null);
386
- const head = `Install job: ${status.state} — ${status.phase} ${dim(`(v${status.caeloVersion}, execution ${status.execution}, updated ${status.updatedAt})`)}`;
387
- const lines = [head];
401
+ : null;
402
+ return { status, decision: decideInstallJob(status, live) };
403
+ }
404
+ /** {@link InstallJobView} as `status` prints it, with the command that goes on from there. */
405
+ export function installJobViewLines(view, meta) {
406
+ const { status, decision } = view;
407
+ const lines = [
408
+ `Install job: ${status.state} — ${status.phase} ${dim(`(v${status.caeloVersion}, execution ${status.execution}, updated ${status.updatedAt})`)}`,
409
+ ];
388
410
  if (status.detail)
389
411
  lines.push(` ${status.detail}`);
390
412
  if (decision.kind === "attach") {
391
- lines.push(` Follow it: re-run the installer for project ${meta.projectId} (it attaches).`);
413
+ lines.push(` Follow it live: ${installerCommand(meta)}`);
392
414
  }
393
415
  else if (decision.kind === "start") {
394
- lines.push(` Not finished (${decision.why}). Re-run the installer for project ${meta.projectId}; it resumes where this run stopped.`);
416
+ lines.push(` Not finished (${decision.why}). Resume it where this run stopped: ${installerCommand(meta)}`);
395
417
  }
396
418
  return lines;
397
419
  }
420
+ /**
421
+ * `status`'s view of the install job as text. Empty when the install never
422
+ * used the job.
423
+ */
424
+ export async function installJobStatusLines(meta, deps = { run: gcloud, syncRun: realSyncGcloud }) {
425
+ const view = await readInstallJobView(meta, deps);
426
+ return view ? installJobViewLines(view, meta) : [];
427
+ }
398
428
  //# sourceMappingURL=gcp-install-job.js.map