Skip to content

Commit c47ad11

Browse files
dario-piotrowiczvicbpenalosa
authored
Support internal-only undocumented cross_account_grant service binding property (#11335)
* Support internal-only undocumented `cross_account_grant` service binding property * Update .changeset/tiny-melons-take.md Co-authored-by: Somhairle MacLeòid <smacleod@cloudflare.com> * replace @ts-ignore with @ts-expect-error --------- Co-authored-by: Victor Berchet <victor@suumit.com> Co-authored-by: Somhairle MacLeòid <smacleod@cloudflare.com>
1 parent 6e63b57 commit c47ad11

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

.changeset/tiny-melons-take.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Support internal-only undocumented `cross_account_grant` service binding property

packages/workers-utils/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export type WorkerMetadataBinding =
9292
service: string;
9393
environment?: string;
9494
entrypoint?: string;
95+
cross_account_grant?: string;
9596
}
9697
| { type: "analytics_engine"; name: string; dataset?: string }
9798
| {

packages/workers-utils/src/worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ export interface CfService {
256256
entrypoint?: string;
257257
props?: Record<string, unknown>;
258258
remote?: boolean;
259+
cross_account_grant?: string;
259260
}
260261

261262
export interface CfVpcService {

packages/wrangler/src/__tests__/deploy.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10722,6 +10722,50 @@ addEventListener('fetch', event => {});`
1072210722
expect(std.err).toMatchInlineSnapshot(`""`);
1072310723
expect(std.warn).toMatchInlineSnapshot(`""`);
1072410724
});
10725+
10726+
it("should support the internal and non-public facing cross_account_grant service binding field", async () => {
10727+
writeWranglerConfig({
10728+
services: [
10729+
{
10730+
binding: "FOO",
10731+
service: "foo-service",
10732+
// @ts-expect-error - cross_account_gran is purposely not included in the config types (since it is an internal-only feature)
10733+
cross_account_grant: "grant-service",
10734+
},
10735+
],
10736+
});
10737+
writeWorkerSource();
10738+
mockSubDomainRequest();
10739+
mockUploadWorkerRequest({
10740+
expectedBindings: [
10741+
{
10742+
cross_account_grant: "grant-service",
10743+
name: "FOO",
10744+
service: "foo-service",
10745+
type: "service",
10746+
},
10747+
],
10748+
});
10749+
10750+
await runWrangler("deploy index.js");
10751+
expect(std.out).toMatchInlineSnapshot(`
10752+
"
10753+
⛅️ wrangler x.x.x
10754+
──────────────────
10755+
Total Upload: xx KiB / gzip: xx KiB
10756+
Worker Startup Time: 100 ms
10757+
Your Worker has access to the following bindings:
10758+
Binding Resource
10759+
env.FOO (foo-service) Worker
10760+
10761+
Uploaded test-name (TIMINGS)
10762+
Deployed test-name triggers (TIMINGS)
10763+
https://test-name.test-sub-domain.workers.dev
10764+
Current Version ID: Galaxy-Class"
10765+
`);
10766+
expect(std.err).toMatchInlineSnapshot(`""`);
10767+
expect(std.warn).toMatchInlineSnapshot(`""`);
10768+
});
1072510769
});
1072610770

1072710771
describe("[analytics_engine_datasets]", () => {

packages/wrangler/src/deploy/deploy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
913913
props.config
914914
);
915915
}
916+
916917
workerBundle = createWorkerUploadForm(worker);
917918

918919
await ensureQueuesExistByConfig(config);

packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,19 @@ export function createWorkerUploadForm(
305305
});
306306

307307
bindings.services?.forEach(
308-
({ binding, service, environment, entrypoint, props }) => {
308+
({
309+
binding,
310+
service,
311+
environment,
312+
entrypoint,
313+
props,
314+
cross_account_grant,
315+
}) => {
309316
metadataBindings.push({
310317
name: binding,
311318
type: "service",
312319
service,
320+
cross_account_grant,
313321
...(environment && { environment }),
314322
...(entrypoint && { entrypoint }),
315323
...(props && { props }),

0 commit comments

Comments
 (0)