@caelo-cms/provisioning 0.11.19 → 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.
- package/dist/admin-internal-google.d.ts +13 -1
- package/dist/admin-internal-google.d.ts.map +1 -1
- package/dist/admin-internal-google.js +47 -0
- package/dist/admin-internal-google.js.map +1 -1
- package/dist/agent/command.d.ts +1 -1
- package/dist/agent-db.js +32 -0
- package/dist/aws-task-roles.d.ts +11 -0
- package/dist/aws-task-roles.d.ts.map +1 -1
- package/dist/aws-task-roles.js +19 -0
- package/dist/aws-task-roles.js.map +1 -1
- package/dist/azure-secrets.d.ts +22 -0
- package/dist/azure-secrets.d.ts.map +1 -0
- package/dist/azure-secrets.js +14 -0
- package/dist/azure-secrets.js.map +1 -0
- package/dist/caddy.d.ts +7 -0
- package/dist/caddy.d.ts.map +1 -1
- package/dist/caddy.js +22 -1
- package/dist/caddy.js.map +1 -1
- package/dist/cli-routing.d.ts.map +1 -1
- package/dist/cli-routing.js +2 -2
- package/dist/cli-routing.js.map +1 -1
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -1
- package/dist/converge-checkpoint.d.ts +6 -0
- package/dist/converge-checkpoint.d.ts.map +1 -1
- package/dist/dns/manual.d.ts +5 -1
- package/dist/dns/manual.d.ts.map +1 -1
- package/dist/dns/manual.js +2 -1
- package/dist/dns/manual.js.map +1 -1
- package/dist/gateway-armor.d.ts +24 -0
- package/dist/gateway-armor.d.ts.map +1 -0
- package/dist/gateway-armor.js +118 -0
- package/dist/gateway-armor.js.map +1 -0
- package/dist/gateway-edge.d.ts +128 -0
- package/dist/gateway-edge.d.ts.map +1 -0
- package/dist/gateway-edge.js +211 -0
- package/dist/gateway-edge.js.map +1 -0
- package/dist/infra-contract.d.ts +1 -1
- package/dist/infra-contract.d.ts.map +1 -1
- package/dist/infra-contract.js +21 -1
- package/dist/infra-contract.js.map +1 -1
- package/dist/install-job-runner.d.ts.map +1 -1
- package/dist/install-job-runner.js +4 -3
- package/dist/install-job-runner.js.map +1 -1
- package/dist/install-job.d.ts +25 -1
- package/dist/install-job.d.ts.map +1 -1
- package/dist/install-job.js +72 -3
- package/dist/install-job.js.map +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +8 -1
- package/dist/lifecycle.js.map +1 -1
- package/dist/operator-access.d.ts +7 -2
- package/dist/operator-access.d.ts.map +1 -1
- package/dist/operator-access.js +37 -6
- package/dist/operator-access.js.map +1 -1
- package/dist/pool-budget-stack.d.ts +22 -0
- package/dist/pool-budget-stack.d.ts.map +1 -1
- package/dist/pool-budget-stack.js +22 -1
- package/dist/pool-budget-stack.js.map +1 -1
- package/dist/project-status.d.ts +95 -0
- package/dist/project-status.d.ts.map +1 -0
- package/dist/project-status.js +213 -0
- package/dist/project-status.js.map +1 -0
- package/dist/public-service-shape.d.ts +45 -0
- package/dist/public-service-shape.d.ts.map +1 -0
- package/dist/public-service-shape.js +90 -0
- package/dist/public-service-shape.js.map +1 -0
- package/dist/remote-mcp-edge.d.ts +1 -1
- package/dist/remote-mcp-edge.js +1 -1
- package/dist/remote-mcp.d.ts.map +1 -1
- package/dist/remote-mcp.js +12 -2
- package/dist/remote-mcp.js.map +1 -1
- package/dist/serverless-backend.d.ts +27 -0
- package/dist/serverless-backend.d.ts.map +1 -0
- package/dist/serverless-backend.js +30 -0
- package/dist/serverless-backend.js.map +1 -0
- package/dist/stack-contract.d.ts +6 -0
- package/dist/stack-contract.d.ts.map +1 -1
- package/dist/stack-contract.js +24 -0
- package/dist/stack-contract.js.map +1 -1
- package/dist/stack-converge.d.ts +13 -0
- package/dist/stack-converge.d.ts.map +1 -1
- package/dist/stack-converge.js +27 -0
- package/dist/stack-converge.js.map +1 -1
- package/dist/staging-gateway-setup.d.ts +5 -0
- package/dist/staging-gateway-setup.d.ts.map +1 -1
- package/dist/staging-gateway-setup.js +60 -19
- package/dist/staging-gateway-setup.js.map +1 -1
- package/dist/state-attach.d.ts +17 -0
- package/dist/state-attach.d.ts.map +1 -1
- package/dist/state-attach.js +27 -9
- package/dist/state-attach.js.map +1 -1
- package/dist/upgrade/app-roll.d.ts +5 -1
- package/dist/upgrade/app-roll.d.ts.map +1 -1
- package/dist/upgrade/app-roll.js +20 -3
- package/dist/upgrade/app-roll.js.map +1 -1
- package/dist/upgrade/converge.d.ts.map +1 -1
- package/dist/upgrade/converge.js +27 -4
- package/dist/upgrade/converge.js.map +1 -1
- package/dist/upgrade/health.d.ts +13 -3
- package/dist/upgrade/health.d.ts.map +1 -1
- package/dist/upgrade/health.js +24 -7
- package/dist/upgrade/health.js.map +1 -1
- package/dist/upgrade/load-balancer-get.d.ts +17 -0
- package/dist/upgrade/load-balancer-get.d.ts.map +1 -0
- package/dist/upgrade/load-balancer-get.js +38 -0
- package/dist/upgrade/load-balancer-get.js.map +1 -0
- package/dist/upgrader-gcp.d.ts.map +1 -1
- package/dist/upgrader-gcp.js +8 -1
- package/dist/upgrader-gcp.js.map +1 -1
- package/dist/wizards/gcp-cost.d.ts +9 -0
- package/dist/wizards/gcp-cost.d.ts.map +1 -1
- package/dist/wizards/gcp-cost.js +69 -34
- package/dist/wizards/gcp-cost.js.map +1 -1
- package/dist/wizards/gcp-install-job.d.ts +27 -4
- package/dist/wizards/gcp-install-job.d.ts.map +1 -1
- package/dist/wizards/gcp-install-job.js +62 -32
- package/dist/wizards/gcp-install-job.js.map +1 -1
- package/dist/wizards/gcp.d.ts +3 -0
- package/dist/wizards/gcp.d.ts.map +1 -1
- package/dist/wizards/gcp.js +10 -4
- package/dist/wizards/gcp.js.map +1 -1
- package/package.json +2 -2
- package/src/admin-internal-google.ts +48 -0
- package/src/aws-task-roles.ts +22 -0
- package/src/azure-secrets.ts +38 -0
- package/src/caddy.test.ts +19 -2
- package/src/caddy.ts +23 -0
- package/src/cli-routing.ts +3 -2
- package/src/cli.ts +10 -0
- package/src/dns/manual.ts +4 -1
- package/src/gateway-armor.ts +135 -0
- package/src/gateway-bootstrap.test.ts +1 -0
- package/src/gateway-edge.test.ts +262 -0
- package/src/gateway-edge.ts +256 -0
- package/src/gateway-env-isolation.test.ts +45 -6
- package/src/infra-contract.test.ts +5 -3
- package/src/infra-contract.ts +21 -1
- package/src/install-job-runner.ts +4 -2
- package/src/install-job.ts +86 -4
- package/src/lifecycle.ts +8 -1
- package/src/operator-access.test.ts +43 -0
- package/src/operator-access.ts +38 -6
- package/src/pool-budget-stack.ts +25 -0
- package/src/pool-budget-stacks.test.ts +31 -0
- package/src/project-status.test.ts +462 -0
- package/src/project-status.ts +306 -0
- package/src/public-service-shape.test.ts +166 -0
- package/src/public-service-shape.ts +131 -0
- package/src/remote-mcp-edge.ts +1 -1
- package/src/remote-mcp.test.ts +38 -1
- package/src/remote-mcp.ts +25 -3
- package/src/serverless-backend.ts +47 -0
- package/src/stack-contract.test.ts +13 -0
- package/src/stack-contract.ts +25 -0
- package/src/stack-converge.test.ts +28 -1
- package/src/stack-converge.ts +30 -0
- package/src/staging-gateway-setup.test.ts +55 -3
- package/src/staging-gateway-setup.ts +79 -27
- package/src/state-attach.ts +46 -16
- package/src/upgrade/app-roll.ts +27 -3
- package/src/upgrade/converge.ts +33 -4
- package/src/upgrade/health.test.ts +88 -13
- package/src/upgrade/health.ts +32 -7
- package/src/upgrade/load-balancer-get.ts +64 -0
- package/src/upgrade/upgrade.test.ts +96 -3
- package/src/upgrader-gcp.ts +8 -1
- package/src/wizards/gcp-cost.ts +78 -35
- package/src/wizards/gcp-install-job.ts +91 -46
- package/src/wizards/gcp.ts +14 -7
- package/stacks/aws/index.ts +24 -22
- package/stacks/azure/index.ts +152 -64
- package/stacks/gcp/index.ts +35 -47
- package/stacks/gcp-firebase/index.ts +25 -13
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `cms-provision status --project <id>` (#822): where an install stands, on
|
|
5
|
+
* any machine. The install job keeps running after the Cloud Shell tab is
|
|
6
|
+
* gone, and a reset Cloud Shell has no `~/.caelo-*` left, so this command
|
|
7
|
+
* needs nothing but a signed-in gcloud identity: it reads the project
|
|
8
|
+
* (install.json, install-job.json and progress.json in the ops bucket, the
|
|
9
|
+
* Owner setup link in Secret Manager) and writes nothing, here or there.
|
|
10
|
+
*
|
|
11
|
+
* The setup link is a secret (#656). It goes to a terminal only: with stdout
|
|
12
|
+
* piped or redirected it stays unprinted, so it can't land in a CI log or a
|
|
13
|
+
* file. Once Owner setup is done the command says so instead of showing a
|
|
14
|
+
* used link.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { log } from "@clack/prompts";
|
|
18
|
+
import { bold, cyan, dim, green, red, yellow } from "kleur/colors";
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
import type { AdminInternalResult, GoogleAdminTarget } from "./admin-internal.js";
|
|
21
|
+
import { readOwnerSetupState } from "./admin-internal-google.js";
|
|
22
|
+
import {
|
|
23
|
+
type DnsRecordGroups,
|
|
24
|
+
formatDnsRecordGroups,
|
|
25
|
+
groupDnsRecords,
|
|
26
|
+
type InstallDnsRecord,
|
|
27
|
+
} from "./dns/groups.js";
|
|
28
|
+
import { checkRecord } from "./dns/manual.js";
|
|
29
|
+
import { checkGcloudAuth, gcloud } from "./gcloud.js";
|
|
30
|
+
import type { GcloudRunner } from "./gcloud-retry.js";
|
|
31
|
+
import {
|
|
32
|
+
INSTALL_SETUP_LINK_SECRET,
|
|
33
|
+
isGcpProjectId,
|
|
34
|
+
readRecordedStackOutputs,
|
|
35
|
+
readSetupLink,
|
|
36
|
+
recordedDnsRecords,
|
|
37
|
+
} from "./install-job.js";
|
|
38
|
+
import { readProjectInstall } from "./state-attach.js";
|
|
39
|
+
import { realSyncGcloud, type SyncGcloud } from "./state-store.js";
|
|
40
|
+
import {
|
|
41
|
+
type InstallJobView,
|
|
42
|
+
installerCommand,
|
|
43
|
+
installJobViewLines,
|
|
44
|
+
readInstallJobView,
|
|
45
|
+
} from "./wizards/gcp-install-job.js";
|
|
46
|
+
|
|
47
|
+
/** The parts of install.json this command reads. */
|
|
48
|
+
const InstallRecordSchema = z.object({
|
|
49
|
+
installId: z.string().min(1),
|
|
50
|
+
provider: z.enum(["gcp", "gcp-firebase"]),
|
|
51
|
+
domain: z.string().min(1),
|
|
52
|
+
ownerEmail: z.string().min(1),
|
|
53
|
+
projectId: z.string().min(1),
|
|
54
|
+
region: z.string().min(1).nullable().default(null),
|
|
55
|
+
});
|
|
56
|
+
type InstallRecord = z.infer<typeof InstallRecordSchema>;
|
|
57
|
+
|
|
58
|
+
/** The DNS records of an install that public DNS does not answer yet. */
|
|
59
|
+
export interface DnsToSet extends DnsRecordGroups<InstallDnsRecord> {
|
|
60
|
+
/** How many records the install knows about, set or not; 0 before the stack ran. */
|
|
61
|
+
readonly total: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Where Owner setup stands, as far as this command can tell. */
|
|
65
|
+
export type OwnerSetup =
|
|
66
|
+
/** The install has not got far enough for a link to exist. */
|
|
67
|
+
| { readonly kind: "not-yet" }
|
|
68
|
+
/** An Owner exists; the link is used. */
|
|
69
|
+
| { readonly kind: "done" }
|
|
70
|
+
/** Setup is open, or could not be checked ({@link unverified} says why). */
|
|
71
|
+
| { readonly kind: "link"; readonly link: string; readonly unverified: string | null }
|
|
72
|
+
/** A link exists, but stdout is not a terminal. */
|
|
73
|
+
| { readonly kind: "withheld" }
|
|
74
|
+
/** No link in Secret Manager. */
|
|
75
|
+
| { readonly kind: "no-link" }
|
|
76
|
+
/** Reading the link failed; the message says what the account needs. */
|
|
77
|
+
| { readonly kind: "error"; readonly message: string };
|
|
78
|
+
|
|
79
|
+
/** Everything `status --project` shows. */
|
|
80
|
+
export interface ProjectStatus {
|
|
81
|
+
readonly install: InstallRecord;
|
|
82
|
+
readonly job: InstallJobView | null;
|
|
83
|
+
/** Whether the stack ran (its outputs are recorded). */
|
|
84
|
+
readonly provisioned: boolean;
|
|
85
|
+
readonly adminUrl: string | null;
|
|
86
|
+
readonly dns: DnsToSet;
|
|
87
|
+
readonly owner: OwnerSetup;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Side effects of {@link readProjectStatus}, injectable for tests. */
|
|
91
|
+
export interface ProjectStatusDeps {
|
|
92
|
+
readonly run: GcloudRunner;
|
|
93
|
+
readonly syncRun: SyncGcloud;
|
|
94
|
+
/** Whether public DNS answers the record with its value. */
|
|
95
|
+
readonly resolves: (record: InstallDnsRecord) => Promise<boolean>;
|
|
96
|
+
/** Whether the admin still offers Owner setup ({@link readOwnerSetupState}). */
|
|
97
|
+
readonly ownerSetupState: (
|
|
98
|
+
target: GoogleAdminTarget,
|
|
99
|
+
) => Promise<AdminInternalResult<"open" | "done">>;
|
|
100
|
+
/** Whether stdout is a terminal: the only place the setup link may go. */
|
|
101
|
+
readonly isTerminal: boolean;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The admin's origin from the stack's outputs; null before the stack ran. */
|
|
105
|
+
export function adminUrlFromOutputs(
|
|
106
|
+
provider: InstallRecord["provider"],
|
|
107
|
+
outputs: Record<string, unknown>,
|
|
108
|
+
): string | null {
|
|
109
|
+
// gcp-firebase binds admin.<domain> only on request; the setup link and
|
|
110
|
+
// the install's summary use the Cloud Run URL there (wizards/gcp.ts).
|
|
111
|
+
if (provider === "gcp-firebase") {
|
|
112
|
+
const url = outputs.adminCloudRunUrlOut;
|
|
113
|
+
return typeof url === "string" && url !== "" ? url : null;
|
|
114
|
+
}
|
|
115
|
+
const host = outputs.adminDomainOut;
|
|
116
|
+
return typeof host === "string" && host !== "" ? `https://${host}` : null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Split `records` by what still has to happen: a record public DNS already
|
|
121
|
+
* answers is dropped, the rest fall into {@link groupDnsRecords}'s two groups.
|
|
122
|
+
*/
|
|
123
|
+
export async function dnsRecordsToSet(
|
|
124
|
+
records: readonly InstallDnsRecord[],
|
|
125
|
+
domain: string,
|
|
126
|
+
resolves: ProjectStatusDeps["resolves"],
|
|
127
|
+
): Promise<DnsToSet> {
|
|
128
|
+
const unique = [
|
|
129
|
+
...new Map(records.map((r) => [`${r.type}:${r.hostname}:${r.value}`, r])).values(),
|
|
130
|
+
];
|
|
131
|
+
const answered = await Promise.all(unique.map(resolves));
|
|
132
|
+
const open = unique.filter((_, i) => !answered[i]);
|
|
133
|
+
return { ...groupDnsRecords(open, domain), total: unique.length };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Where {@link readOwnerSetupState} reaches the admin; null without a recorded region. */
|
|
137
|
+
function adminTarget(install: InstallRecord): GoogleAdminTarget | null {
|
|
138
|
+
const { provider, projectId, domain, region } = install;
|
|
139
|
+
if (provider === "gcp") return { provider, projectId, domain };
|
|
140
|
+
return region ? { provider, projectId, region } : null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function readOwnerSetup(
|
|
144
|
+
args: {
|
|
145
|
+
readonly install: InstallRecord;
|
|
146
|
+
readonly adminUrl: string | null;
|
|
147
|
+
readonly job: InstallJobView | null;
|
|
148
|
+
readonly provisioned: boolean;
|
|
149
|
+
},
|
|
150
|
+
deps: ProjectStatusDeps,
|
|
151
|
+
): Promise<OwnerSetup> {
|
|
152
|
+
const unfinished = args.job ? args.job.decision.kind !== "done" : !args.provisioned;
|
|
153
|
+
if (unfinished || args.adminUrl === null) return { kind: "not-yet" };
|
|
154
|
+
let link: string | null;
|
|
155
|
+
try {
|
|
156
|
+
link = await readSetupLink(deps.run, args.install.projectId);
|
|
157
|
+
} catch (e) {
|
|
158
|
+
return { kind: "error", message: e instanceof Error ? e.message : String(e) };
|
|
159
|
+
}
|
|
160
|
+
if (link === null) return { kind: "no-link" };
|
|
161
|
+
const target = adminTarget(args.install);
|
|
162
|
+
const state: AdminInternalResult<"open" | "done"> = target
|
|
163
|
+
? await deps.ownerSetupState(target)
|
|
164
|
+
: { ok: false, error: "install.json records no region" };
|
|
165
|
+
if (state.ok && state.value === "done") return { kind: "done" };
|
|
166
|
+
if (!deps.isTerminal) return { kind: "withheld" };
|
|
167
|
+
return { kind: "link", link, unverified: state.ok ? null : state.error };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Read where the install in `projectId` stands from the project alone.
|
|
172
|
+
*
|
|
173
|
+
* @throws when a read fails, with what to do about it
|
|
174
|
+
*/
|
|
175
|
+
export async function readProjectStatus(
|
|
176
|
+
projectId: string,
|
|
177
|
+
deps: ProjectStatusDeps,
|
|
178
|
+
): Promise<ProjectStatus> {
|
|
179
|
+
const record = readProjectInstall(projectId, deps.syncRun);
|
|
180
|
+
if (!record.ok) throw new Error(record.error);
|
|
181
|
+
const parsed = InstallRecordSchema.safeParse(JSON.parse(record.text));
|
|
182
|
+
if (!parsed.success) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
`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.`,
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
const install = parsed.data;
|
|
188
|
+
const job = await readInstallJobView(install, deps);
|
|
189
|
+
const outputs = readRecordedStackOutputs(projectId, deps.syncRun);
|
|
190
|
+
const provisioned = Object.keys(outputs).length > 0;
|
|
191
|
+
const adminUrl = adminUrlFromOutputs(install.provider, outputs);
|
|
192
|
+
const dns = await dnsRecordsToSet(
|
|
193
|
+
[...recordedDnsRecords(outputs), ...(job?.status.dnsRecords ?? [])],
|
|
194
|
+
install.domain,
|
|
195
|
+
deps.resolves,
|
|
196
|
+
);
|
|
197
|
+
const owner = await readOwnerSetup({ install, adminUrl, job, provisioned }, deps);
|
|
198
|
+
return { install, job, provisioned, adminUrl, dns, owner };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function jobLines(s: ProjectStatus): string[] {
|
|
202
|
+
if (s.job) return installJobViewLines(s.job, s.install);
|
|
203
|
+
return s.provisioned
|
|
204
|
+
? ["Install job: none. This install ran from a terminal, not through the job."]
|
|
205
|
+
: [`Install job: not started. Start or resume it: ${installerCommand(s.install)}`];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function dnsLines(s: ProjectStatus): string[] {
|
|
209
|
+
const { dns, install } = s;
|
|
210
|
+
if (dns.total === 0) {
|
|
211
|
+
return ["DNS: not known yet; the install reports its records once its resources exist."];
|
|
212
|
+
}
|
|
213
|
+
const lines =
|
|
214
|
+
dns.setNow.length + dns.atGoLive.length === 0
|
|
215
|
+
? [`DNS: ${green(`all set (${dns.total} of ${dns.total}).`)}`]
|
|
216
|
+
: [
|
|
217
|
+
`DNS records still to set for ${bold(install.domain)}:`,
|
|
218
|
+
...formatDnsRecordGroups(dns, install.domain).map((l) => ` ${l}`),
|
|
219
|
+
];
|
|
220
|
+
// The staging host's records reach the status document only through the
|
|
221
|
+
// job; a terminal install or an older job recorded none there.
|
|
222
|
+
if (!s.job?.status.dnsRecords) {
|
|
223
|
+
lines.push(dim(" The staging host's records are under Settings → Updates in the admin."));
|
|
224
|
+
}
|
|
225
|
+
return lines;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function ownerLines(s: ProjectStatus): string[] {
|
|
229
|
+
const { owner, install, adminUrl } = s;
|
|
230
|
+
const command = installerCommand(install);
|
|
231
|
+
switch (owner.kind) {
|
|
232
|
+
case "not-yet":
|
|
233
|
+
return ["Owner setup: the link appears here when the install has finished."];
|
|
234
|
+
case "done":
|
|
235
|
+
return [`Owner setup: ${green("done.")} Sign in at ${cyan(adminUrl ?? "")}`];
|
|
236
|
+
case "withheld":
|
|
237
|
+
return [
|
|
238
|
+
`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.`,
|
|
239
|
+
];
|
|
240
|
+
case "no-link":
|
|
241
|
+
return [
|
|
242
|
+
`Owner setup: no link is stored in this project (${INSTALL_SETUP_LINK_SECRET}). If Owner setup is done, sign in at ${cyan(adminUrl ?? "")}`,
|
|
243
|
+
` If it is not, this finishes the install and stores a link: ${command}`,
|
|
244
|
+
];
|
|
245
|
+
case "error":
|
|
246
|
+
return [`Owner setup: ${red(owner.message)}`];
|
|
247
|
+
case "link":
|
|
248
|
+
return [
|
|
249
|
+
`Owner setup: open this link in your browser, signed in as ${install.ownerEmail}. Do not share it.`,
|
|
250
|
+
` ${bold(cyan(owner.link))}`,
|
|
251
|
+
...(owner.unverified === null
|
|
252
|
+
? []
|
|
253
|
+
: [
|
|
254
|
+
yellow(
|
|
255
|
+
` Could not check whether it was already used (${owner.unverified}). A used link just opens the sign-in page.`,
|
|
256
|
+
),
|
|
257
|
+
]),
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** {@link ProjectStatus} as text. Holds the setup link only for {@link OwnerSetup} `link`. */
|
|
263
|
+
export function projectStatusLines(s: ProjectStatus): string[] {
|
|
264
|
+
return [
|
|
265
|
+
`Install: ${bold(s.install.installId)} ${dim(`(${s.install.provider})`)}`,
|
|
266
|
+
`Domain: ${bold(s.install.domain)}`,
|
|
267
|
+
`Project: ${bold(s.install.projectId)}`,
|
|
268
|
+
...jobLines(s),
|
|
269
|
+
`Admin: ${s.adminUrl ? cyan(s.adminUrl) : "not known yet"}`,
|
|
270
|
+
...dnsLines(s),
|
|
271
|
+
...ownerLines(s),
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** What to tell the operator about a failure of the command. */
|
|
276
|
+
export function projectStatusFailure(e: unknown): string {
|
|
277
|
+
if ((e as NodeJS.ErrnoException | undefined)?.code === "ENOENT") {
|
|
278
|
+
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.";
|
|
279
|
+
}
|
|
280
|
+
return e instanceof Error ? e.message : String(e);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** `status --project <id>`: print where the install stands; exit 1 when part of it can't be read. */
|
|
284
|
+
export async function projectStatusCommand(argv: readonly string[]): Promise<void> {
|
|
285
|
+
const projectId = argv[argv.indexOf("--project") + 1] ?? "";
|
|
286
|
+
if (!isGcpProjectId(projectId) || argv.includes("--install")) {
|
|
287
|
+
console.error("Usage: cms-provision status --project <gcp-project-id>");
|
|
288
|
+
process.exit(2);
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
const auth = await checkGcloudAuth();
|
|
292
|
+
if (!auth.ok) throw new Error(auth.error);
|
|
293
|
+
const status = await readProjectStatus(projectId, {
|
|
294
|
+
run: gcloud,
|
|
295
|
+
syncRun: realSyncGcloud,
|
|
296
|
+
resolves: checkRecord,
|
|
297
|
+
ownerSetupState: (target) => readOwnerSetupState(target),
|
|
298
|
+
isTerminal: process.stdout.isTTY === true,
|
|
299
|
+
});
|
|
300
|
+
for (const line of projectStatusLines(status)) console.log(line);
|
|
301
|
+
if (status.owner.kind === "error") process.exitCode = 1;
|
|
302
|
+
} catch (e) {
|
|
303
|
+
log.error(red(projectStatusFailure(e)));
|
|
304
|
+
process.exit(1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Epic #763 E11 / #1339 — every adapter provisions the public services in
|
|
5
|
+
* the shape of PUBLIC_SERVICE_SHAPE: at zero minimum instances, behind the
|
|
6
|
+
* edge the table names, with a WAF only where the table says so, and the
|
|
7
|
+
* GCP cost table prices what is provisioned. Pure-string checks on the
|
|
8
|
+
* stack programs and the CLI setup modules, like the other stack tests.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, expect, it } from "bun:test";
|
|
12
|
+
import { readFileSync } from "node:fs";
|
|
13
|
+
import { resolve } from "node:path";
|
|
14
|
+
import type { SupportedProvider } from "./adapter.js";
|
|
15
|
+
import { generateDockerCompose } from "./compose.js";
|
|
16
|
+
import { GATEWAY_ARMOR_BILLED_RULES } from "./gateway-edge.js";
|
|
17
|
+
import { PUBLIC_SERVICE_SHAPE, type PublicService } from "./public-service-shape.js";
|
|
18
|
+
import {
|
|
19
|
+
CLOUD_ARMOR_POLICY_USD,
|
|
20
|
+
CLOUD_ARMOR_RULE_USD,
|
|
21
|
+
estimateGcpCost,
|
|
22
|
+
} from "./wizards/gcp-cost.js";
|
|
23
|
+
|
|
24
|
+
const stack = (provider: SupportedProvider) =>
|
|
25
|
+
readFileSync(resolve(import.meta.dir, `../stacks/${provider}/index.ts`), "utf8");
|
|
26
|
+
const src = (file: string) => readFileSync(resolve(import.meta.dir, file), "utf8");
|
|
27
|
+
|
|
28
|
+
const SERVICES: readonly PublicService[] = ["gateway", "staging-gateway", "mcp-auth-proxy"];
|
|
29
|
+
|
|
30
|
+
/** The `cloudRunService({ serviceName: "<name>", … })` call of a GCP stack. */
|
|
31
|
+
function cloudRunBlock(source: string, name: string): string | null {
|
|
32
|
+
const m = new RegExp(
|
|
33
|
+
`cloudRunService\\(\\{\\s*serviceName: "${name}",([\\s\\S]*?)\\n\\s*\\}\\)`,
|
|
34
|
+
).exec(source);
|
|
35
|
+
return m?.[1] ?? null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe("E11: one public-service shape for every provider", () => {
|
|
39
|
+
for (const provider of ["gcp", "gcp-firebase"] as const) {
|
|
40
|
+
describe(provider, () => {
|
|
41
|
+
const source = stack(provider);
|
|
42
|
+
for (const service of SERVICES) {
|
|
43
|
+
const shape = PUBLIC_SERVICE_SHAPE[provider][service];
|
|
44
|
+
it(`${service}: ${shape.owner.kind}-owned at zero minimum instances`, () => {
|
|
45
|
+
if (shape.owner.kind === "stack") {
|
|
46
|
+
const block = cloudRunBlock(source, service);
|
|
47
|
+
expect(block).not.toBeNull();
|
|
48
|
+
// The gateway's minimum is the §11.B knob, which defaults to 0.
|
|
49
|
+
const min = service === "gateway" ? "gatewayMinInstances" : "0";
|
|
50
|
+
expect(block).toContain(`minInstances: ${min},`);
|
|
51
|
+
expect(source).toContain(
|
|
52
|
+
`const gatewayMinInstances = Number.parseInt(cfg.get("gatewayMinInstances") ?? "0", 10);`,
|
|
53
|
+
);
|
|
54
|
+
} else if (shape.owner.kind === "cli") {
|
|
55
|
+
const setup = src(shape.owner.module);
|
|
56
|
+
expect(setup).toContain('"--min-instances=0"');
|
|
57
|
+
expect(setup).toContain('"--cpu-throttling"');
|
|
58
|
+
// The stack does not declare what the CLI owns.
|
|
59
|
+
expect(cloudRunBlock(source, service)).toBeNull();
|
|
60
|
+
} else {
|
|
61
|
+
throw new Error(`${provider} ${service}: unexpected owner ${shape.owner.kind}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
it(`a WAF only where the table says so (${provider})`, () => {
|
|
66
|
+
const anyWaf = SERVICES.some((s) => PUBLIC_SERVICE_SHAPE[provider][s].waf !== "none");
|
|
67
|
+
if (anyWaf) {
|
|
68
|
+
expect(source).toContain("new gcp.compute.SecurityPolicy(");
|
|
69
|
+
expect(source).toMatch(/function gatewayBackend\([\s\S]*?securityPolicy: wafPolicy\.id/);
|
|
70
|
+
} else {
|
|
71
|
+
// E3: the cheap setup has no load balancer and no WAF.
|
|
72
|
+
expect(source).not.toContain("SecurityPolicy");
|
|
73
|
+
expect(source).not.toContain("gcp.compute.URLMap");
|
|
74
|
+
expect(source).not.toContain("BackendService(");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
it("self-hosted runs every public service in Compose", () => {
|
|
81
|
+
const compose = generateDockerCompose({
|
|
82
|
+
domain: "acme.com",
|
|
83
|
+
postgresPassword: "pw",
|
|
84
|
+
rolePasswords: { admin: "a", public: "b", publicStaging: "ps" },
|
|
85
|
+
caeloSecretKek: "0".repeat(64),
|
|
86
|
+
dbTlsServerCertSha256: "ab".repeat(32),
|
|
87
|
+
internalSecret: "i".repeat(48),
|
|
88
|
+
stagingHost: "staging.acme.com",
|
|
89
|
+
stagingGateSecret: "g".repeat(64),
|
|
90
|
+
diskSize: "20Gi",
|
|
91
|
+
ports: { http: 80, https: 443 },
|
|
92
|
+
project: "caelo-acme-com",
|
|
93
|
+
images: {
|
|
94
|
+
mode: "release" as const,
|
|
95
|
+
admin: `ghcr.io/caelo-cms/admin@sha256:${"a".repeat(64)}`,
|
|
96
|
+
gateway: `ghcr.io/caelo-cms/gateway@sha256:${"b".repeat(64)}`,
|
|
97
|
+
"mcp-auth-proxy": `ghcr.io/caelo-cms/mcp-auth-proxy@sha256:${"c".repeat(64)}`,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
for (const service of SERVICES) {
|
|
101
|
+
const owner = PUBLIC_SERVICE_SHAPE["self-hosted"][service].owner;
|
|
102
|
+
if (owner.kind !== "compose") throw new Error(`self-hosted ${service} is not in Compose`);
|
|
103
|
+
expect(compose).toContain(`\n ${owner.service}:\n`);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("aws refuses honestly until #749: no public service, the gap named", () => {
|
|
108
|
+
const source = stack("aws");
|
|
109
|
+
for (const service of SERVICES) {
|
|
110
|
+
expect(PUBLIC_SERVICE_SHAPE.aws[service].owner).toEqual({ kind: "refused", issue: "#749" });
|
|
111
|
+
}
|
|
112
|
+
expect(source).not.toContain("new aws.ecs.Service(");
|
|
113
|
+
expect(source).not.toContain("new aws.ecs.TaskDefinition(");
|
|
114
|
+
expect(source).toContain("FIXME(issue #749)");
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("azure: the gateway scales to zero by default, the proxy always; staging refused until #750", () => {
|
|
118
|
+
const source = stack("azure");
|
|
119
|
+
expect(source).toContain(
|
|
120
|
+
`const gatewayMinInstances = Number.parseInt(cfg.get("gatewayMinInstances") ?? "0", 10);`,
|
|
121
|
+
);
|
|
122
|
+
expect(source).toMatch(/serviceName: "gateway",[\s\S]*?minReplicas: gatewayMinInstances,/);
|
|
123
|
+
expect(source).toMatch(/serviceName: "mcp-auth-proxy",[\s\S]*?isolated: true,/);
|
|
124
|
+
expect(source).toContain("minReplicas: args.isolated ? 0 :");
|
|
125
|
+
expect(PUBLIC_SERVICE_SHAPE.azure["staging-gateway"].owner).toEqual({
|
|
126
|
+
kind: "refused",
|
|
127
|
+
issue: "#750",
|
|
128
|
+
});
|
|
129
|
+
expect(source).not.toContain('serviceName: "staging-gateway"');
|
|
130
|
+
expect(source).not.toContain("WebApplicationFirewallPolicy");
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe("the GCP cost table prices every provisioned public service (§11.C)", () => {
|
|
135
|
+
for (const provider of ["gcp", "gcp-firebase"] as const) {
|
|
136
|
+
const { lines } = estimateGcpCost({
|
|
137
|
+
cloudSqlTier: "db-f1-micro",
|
|
138
|
+
cloudSqlHa: false,
|
|
139
|
+
adminMinInstances: 0,
|
|
140
|
+
gatewayMinInstances: 0,
|
|
141
|
+
wafAdaptiveProtection: false,
|
|
142
|
+
provider,
|
|
143
|
+
region: "europe-west1",
|
|
144
|
+
});
|
|
145
|
+
const names = lines.map((l) => l.name);
|
|
146
|
+
it(`${provider}: a Cloud Run line per public service`, () => {
|
|
147
|
+
expect(names.some((n) => /Cloud Run (data )?gateway$/.test(n))).toBe(true);
|
|
148
|
+
expect(names).toContain("Cloud Run staging gateway");
|
|
149
|
+
expect(names).toContain("Cloud Run MCP-Auth-Proxy");
|
|
150
|
+
});
|
|
151
|
+
it(`${provider}: Cloud Armor lines exactly where the table has a WAF`, () => {
|
|
152
|
+
const armor = lines.filter((l) => l.name.includes("Cloud Armor"));
|
|
153
|
+
const wafs = SERVICES.filter((s) => PUBLIC_SERVICE_SHAPE[provider][s].waf === "cloud-armor");
|
|
154
|
+
if (wafs.length === 0) {
|
|
155
|
+
expect(armor).toEqual([]);
|
|
156
|
+
expect(names.some((n) => n.startsWith("Load balancer"))).toBe(false);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
// Two policies: the gateways' (shared with the staging gateway) and the proxy's.
|
|
160
|
+
expect(armor.map((l) => l.monthlyUsd)).toEqual([
|
|
161
|
+
CLOUD_ARMOR_POLICY_USD + GATEWAY_ARMOR_BILLED_RULES * CLOUD_ARMOR_RULE_USD,
|
|
162
|
+
CLOUD_ARMOR_POLICY_USD + 2 * CLOUD_ARMOR_RULE_USD,
|
|
163
|
+
]);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Epic #763 E11 — one shape for every provider: the three public services,
|
|
5
|
+
* which edge sits in front of each, whether a WAF is part of it, and who
|
|
6
|
+
* provisions it. Only the primitive differs per provider. aws and azure
|
|
7
|
+
* host the shape once #749 / #750 land; until then they refuse honestly
|
|
8
|
+
* (no service, or a service that answers the fixed 404).
|
|
9
|
+
*
|
|
10
|
+
* Two rules hold for every row (E14 a): a public service is always
|
|
11
|
+
* provisioned at zero minimum instances (the gateway's minimum is the
|
|
12
|
+
* operator's `gatewayMinInstances` knob, default 0), and while its feature
|
|
13
|
+
* is off it answers a fixed 404 before it reads the request. No row needs
|
|
14
|
+
* a WAF (E3): `cloud-armor` is an extra layer where the provider has one.
|
|
15
|
+
*
|
|
16
|
+
* public-service-shape.test.ts pins every stack, CLI setup module and the
|
|
17
|
+
* Compose file to this table, and the GCP cost table to its billable rows.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { SupportedProvider } from "./adapter.js";
|
|
21
|
+
|
|
22
|
+
/** The public services of an install (CLAUDE.md §11.B Tier 3 and the MCP-Auth-Proxy). */
|
|
23
|
+
export type PublicService = "gateway" | "staging-gateway" | "mcp-auth-proxy";
|
|
24
|
+
|
|
25
|
+
/** One provider's primitive for one public service. */
|
|
26
|
+
export interface PublicServiceShape {
|
|
27
|
+
/**
|
|
28
|
+
* Who creates it: the Pulumi stack, the CLI's setup module (named), the
|
|
29
|
+
* self-hosted Compose file, or nobody yet (`refused`, with the issue).
|
|
30
|
+
*/
|
|
31
|
+
readonly owner:
|
|
32
|
+
| { readonly kind: "stack" }
|
|
33
|
+
| { readonly kind: "cli"; readonly module: string }
|
|
34
|
+
| { readonly kind: "compose"; readonly service: string }
|
|
35
|
+
| { readonly kind: "refused"; readonly issue: string };
|
|
36
|
+
/** What is in front of it on the public internet. */
|
|
37
|
+
readonly edge: string;
|
|
38
|
+
/** A WAF in front of it, as an extra layer only. */
|
|
39
|
+
readonly waf: "cloud-armor" | "none";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The E11 table. */
|
|
43
|
+
export const PUBLIC_SERVICE_SHAPE: Readonly<
|
|
44
|
+
Record<SupportedProvider, Readonly<Record<PublicService, PublicServiceShape>>>
|
|
45
|
+
> = {
|
|
46
|
+
gcp: {
|
|
47
|
+
gateway: {
|
|
48
|
+
owner: { kind: "stack" },
|
|
49
|
+
edge: "the site's load balancer: /api/* → serverless NEG → backend service",
|
|
50
|
+
waf: "cloud-armor",
|
|
51
|
+
},
|
|
52
|
+
"staging-gateway": {
|
|
53
|
+
owner: { kind: "cli", module: "staging-gateway-setup.ts" },
|
|
54
|
+
edge: "the site's load balancer: the staging host's rule → its own backend service",
|
|
55
|
+
waf: "cloud-armor",
|
|
56
|
+
},
|
|
57
|
+
"mcp-auth-proxy": {
|
|
58
|
+
owner: { kind: "cli", module: "mcp-auth-proxy-setup.ts" },
|
|
59
|
+
edge: "the site's load balancer: the MCP paths → its own backend service",
|
|
60
|
+
waf: "cloud-armor",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
"gcp-firebase": {
|
|
64
|
+
gateway: {
|
|
65
|
+
owner: { kind: "stack" },
|
|
66
|
+
edge: "Firebase Hosting rewrite of /api/**, and its run.app URL",
|
|
67
|
+
waf: "none",
|
|
68
|
+
},
|
|
69
|
+
"staging-gateway": {
|
|
70
|
+
owner: { kind: "cli", module: "staging-gateway-setup.ts" },
|
|
71
|
+
edge: "a second Firebase Hosting site's ** rewrite, and its run.app URL",
|
|
72
|
+
waf: "none",
|
|
73
|
+
},
|
|
74
|
+
"mcp-auth-proxy": {
|
|
75
|
+
owner: { kind: "stack" },
|
|
76
|
+
edge: "its own run.app URL",
|
|
77
|
+
waf: "none",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
"self-hosted": {
|
|
81
|
+
gateway: {
|
|
82
|
+
owner: { kind: "compose", service: "caelo-gateway" },
|
|
83
|
+
edge: "Caddy: /api/* on the site's host",
|
|
84
|
+
waf: "none",
|
|
85
|
+
},
|
|
86
|
+
"staging-gateway": {
|
|
87
|
+
owner: { kind: "compose", service: "caelo-staging-gateway" },
|
|
88
|
+
edge: "Caddy: every path of the staging host",
|
|
89
|
+
waf: "none",
|
|
90
|
+
},
|
|
91
|
+
"mcp-auth-proxy": {
|
|
92
|
+
owner: { kind: "compose", service: "caelo-mcp-auth-proxy" },
|
|
93
|
+
edge: "none until remote MCP is available on self-hosted (fixed 404 on the Compose network)",
|
|
94
|
+
waf: "none",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
aws: {
|
|
98
|
+
gateway: {
|
|
99
|
+
owner: { kind: "refused", issue: "#749" },
|
|
100
|
+
edge: "CloudFront → ALB → Fargate, with #749",
|
|
101
|
+
waf: "none",
|
|
102
|
+
},
|
|
103
|
+
"staging-gateway": {
|
|
104
|
+
owner: { kind: "refused", issue: "#749" },
|
|
105
|
+
edge: "with #749",
|
|
106
|
+
waf: "none",
|
|
107
|
+
},
|
|
108
|
+
"mcp-auth-proxy": {
|
|
109
|
+
owner: { kind: "refused", issue: "#749" },
|
|
110
|
+
edge: "its own origin, with #749",
|
|
111
|
+
waf: "none",
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
azure: {
|
|
115
|
+
gateway: {
|
|
116
|
+
owner: { kind: "stack" },
|
|
117
|
+
edge: "Front Door route to its Container App, with #750",
|
|
118
|
+
waf: "none",
|
|
119
|
+
},
|
|
120
|
+
"staging-gateway": {
|
|
121
|
+
owner: { kind: "refused", issue: "#750" },
|
|
122
|
+
edge: "with #750",
|
|
123
|
+
waf: "none",
|
|
124
|
+
},
|
|
125
|
+
"mcp-auth-proxy": {
|
|
126
|
+
owner: { kind: "stack" },
|
|
127
|
+
edge: "its own Container App FQDN (fixed 404: remote MCP needs Google IAP)",
|
|
128
|
+
waf: "none",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
package/src/remote-mcp-edge.ts
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* slows down instead of locking everyone out. Below the threshold the
|
|
34
34
|
* rule's action is `allow`, which ends evaluation: the OWASP packs and the
|
|
35
35
|
* general ban do not run for these paths. Abuse stays bounded by the
|
|
36
|
-
*
|
|
36
|
+
* proxy's max instances and by IAP, which rejects every request
|
|
37
37
|
* without a valid token of an allowlisted user before it reaches the admin.
|
|
38
38
|
*/
|
|
39
39
|
|
package/src/remote-mcp.test.ts
CHANGED
|
@@ -793,7 +793,8 @@ describe("gcp load balancer (remote-mcp-edge)", () => {
|
|
|
793
793
|
expect(planUrlMapPaths([], "acme.com", PROXY_BACKEND).ok).toBe(false);
|
|
794
794
|
});
|
|
795
795
|
|
|
796
|
-
|
|
796
|
+
// As real gcloud prints it: a one-element list.
|
|
797
|
+
const policyJson = (rules: object[]) => ok(JSON.stringify([{ rules }]));
|
|
797
798
|
const PROXY_POLICY = "caelo-production-mcp-auth-proxy-armor";
|
|
798
799
|
|
|
799
800
|
it("#1328 — creates the proxy's own policy and its rule when missing", async () => {
|
|
@@ -927,6 +928,42 @@ describe("gcp load balancer (remote-mcp-edge)", () => {
|
|
|
927
928
|
);
|
|
928
929
|
});
|
|
929
930
|
|
|
931
|
+
it("creates the backend with the http port name a serverless NEG needs", async () => {
|
|
932
|
+
const missing = fakeGcloud({
|
|
933
|
+
"compute network-endpoint-groups describe": ok("caelo-production-mcp-auth-proxy-neg\n"),
|
|
934
|
+
"compute backend-services describe": fail("NOT_FOUND: was not found"),
|
|
935
|
+
"compute backend-services create": ok(JSON.stringify([{ selfLink: PROXY_BACKEND }])),
|
|
936
|
+
});
|
|
937
|
+
await ensureMcpAuthProxyBackend(
|
|
938
|
+
{ projectId: "acme", region: "europe-west1", env: "production" },
|
|
939
|
+
missing,
|
|
940
|
+
);
|
|
941
|
+
expect(missing.calls.find((c) => c.startsWith("compute backend-services create"))).toContain(
|
|
942
|
+
"--protocol=HTTPS --port-name=http",
|
|
943
|
+
);
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
it("repairs a backend an earlier run left with the https port name, before add-backend", async () => {
|
|
947
|
+
const left = fakeGcloud({
|
|
948
|
+
"compute network-endpoint-groups describe": ok("caelo-production-mcp-auth-proxy-neg\n"),
|
|
949
|
+
"compute backend-services describe": ok(
|
|
950
|
+
JSON.stringify({ selfLink: PROXY_BACKEND, portName: "https", backends: [] }),
|
|
951
|
+
),
|
|
952
|
+
"compute backend-services update": ok(),
|
|
953
|
+
"compute backend-services add-backend": ok(),
|
|
954
|
+
});
|
|
955
|
+
const r = await ensureMcpAuthProxyBackend(
|
|
956
|
+
{ projectId: "acme", region: "europe-west1", env: "production" },
|
|
957
|
+
left,
|
|
958
|
+
);
|
|
959
|
+
expect(r.ok).toBe(true);
|
|
960
|
+
const writes = left.calls.filter((c) =>
|
|
961
|
+
/^compute backend-services (update|add-backend)/.test(c),
|
|
962
|
+
);
|
|
963
|
+
expect(writes[0]).toContain("--port-name=http");
|
|
964
|
+
expect(writes.at(-1)).toContain("add-backend");
|
|
965
|
+
});
|
|
966
|
+
|
|
930
967
|
it("#1328 — ensureRemoteMcpEdge: service, policy, backend, URL map, then the gateway rule; no-op on gcp-firebase", async () => {
|
|
931
968
|
expect(
|
|
932
969
|
await ensureRemoteMcpEdge({
|