Skip to content

Commit c34f159

Browse files
committed
fix(gcp): reject unsupported plan protocols in workflow
1 parent 3bcd502 commit c34f159

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

‎packages/gcp-cloud-run/terraform/workflow.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ function chunkRequestBody(): Record<string, unknown> {
3232
}
3333

3434
describe("Cloud Workflows Plan v2 orchestration", () => {
35+
it("defaults an omitted protocol to v2 and rejects every explicit non-v2 value", () => {
36+
expect(source).toContain('default(map.get(args, "PlanProtocol"), "v2")');
37+
expect(namedStep("checkPlanProtocol")).toMatchObject({
38+
switch: [{ condition: '${planProtocol == "v2"}', next: "plan" }],
39+
next: "unsupportedPlanProtocol",
40+
});
41+
expect(namedStep("unsupportedPlanProtocol")).toMatchObject({
42+
raise: { code: "PLAN_PROTOCOL_UNSUPPORTED" },
43+
});
44+
});
45+
3546
it("uses Plan v2 for every distributed action", () => {
3647
for (const body of [requestBody("plan"), chunkRequestBody(), requestBody("assemble")]) {
3748
expect(body.PlanProtocol).toBe("v2");

‎packages/gcp-cloud-run/terraform/workflow.yaml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ main:
1515
- planOutputGcsPrefix: ${args.PlanOutputGcsPrefix}
1616
- outputGcsUri: ${args.OutputGcsUri}
1717
- config: ${args.Config}
18+
- planProtocol: ${default(map.get(args, "PlanProtocol"), "v2")}
19+
20+
- checkPlanProtocol:
21+
switch:
22+
- condition: ${planProtocol == "v2"}
23+
next: plan
24+
next: unsupportedPlanProtocol
25+
26+
- unsupportedPlanProtocol:
27+
raise:
28+
code: PLAN_PROTOCOL_UNSUPPORTED
29+
message: ${"PlanProtocol must be v2 or absent; got " + string(planProtocol)}
1830

1931
- plan:
2032
try:

0 commit comments

Comments
 (0)