Skip to content

Commit

Permalink
Change Pipelines to use name instead of id (#7134)
Browse files Browse the repository at this point in the history
* Pipelines binding change from using id to pipeline name

* adding test for pipelines dev binding

* change references to pipeline id to name

internal ticket: PIPE-124

---------

Co-authored-by: Harry Hough <hhough@cloudflare.com>
  • Loading branch information
cmackenzie1 and hhoughgg authored Nov 1, 2024
1 parent f46330a commit 3ee1353
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-ears-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wrangler": patch
---

Change Pipelines to use name instead of ID
31 changes: 31 additions & 0 deletions packages/wrangler/e2e/dev-with-resources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,37 @@ describe.sequential.each(RUNTIMES)("Bindings: $flags", ({ runtime, flags }) => {
);
});

it.skipIf(!isLocal)("exposes Pipelines bindings", async () => {
await helper.seed({
"wrangler.toml": dedent`
name = "${workerName}"
main = "src/index.ts"
compatibility_date = "2024-10-20"
[[pipelines]]
binding = "PIPELINE"
pipeline = "my-pipeline"
`,
"src/index.ts": dedent`
export default {
async fetch(request, env, ctx) {
if (env.PIPELINE === undefined) {
return new Response("env.PIPELINE is undefined");
}
return new Response("env.PIPELINE is available");
}
}
`,
});

const worker = helper.runLongLived(`wrangler dev ${flags}`);
const { url } = await worker.waitForReady();
const res = await fetch(url);

await expect(res.text()).resolves.toBe("env.PIPELINE is available");
});

it.skipIf(!isLocal)("exposes queue producer/consumer bindings", async () => {
const queueName = generateResourceName("queue");

Expand Down
6 changes: 3 additions & 3 deletions packages/wrangler/src/__tests__/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11239,7 +11239,7 @@ export default{
pipelines: [
{
binding: "MY_PIPELINE",
pipeline: "0123456789ABCDEF0123456789ABCDEF",
pipeline: "my-pipeline",
},
],
});
Expand All @@ -11250,7 +11250,7 @@ export default{
{
type: "pipelines",
name: "MY_PIPELINE",
id: "0123456789ABCDEF0123456789ABCDEF",
pipeline: "my-pipeline",
},
],
});
Expand All @@ -11261,7 +11261,7 @@ export default{
Worker Startup Time: 100 ms
Your worker has access to the following bindings:
- Pipelines:
- MY_PIPELINE: 0123456789ABCDEF0123456789ABCDEF
- MY_PIPELINE: my-pipeline
Uploaded test-name (TIMINGS)
Deployed test-name triggers (TIMINGS)
https://test-name.test-sub-domain.workers.dev
Expand Down
6 changes: 3 additions & 3 deletions packages/wrangler/src/__tests__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ describe("init", () => {
{
type: "pipelines",
name: "PIPELINE_BINDING",
id: "some-id",
pipeline: "some-name",
},
{
type: "mtls_certificate",
Expand Down Expand Up @@ -2670,7 +2670,7 @@ describe("init", () => {
pipelines: [
{
binding: "PIPELINE_BINDING",
pipeline: "some-id",
pipeline: "some-name",
},
],
queues: {
Expand Down Expand Up @@ -3212,7 +3212,7 @@ describe("init", () => {
[[pipelines]]
binding = \\"PIPELINE_BINDING\\"
pipeline = \\"some-id\\"
pipeline = \\"some-name\\"
[[mtls_certificates]]
binding = \\"MTLS_BINDING\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export type WorkerMetadataBinding =
};
}
| { type: "mtls_certificate"; name: string; certificate_id: string }
| { type: "pipelines"; name: string; id: string }
| { type: "pipelines"; name: string; pipeline: string }
| {
type: "logfwdr";
name: string;
Expand Down Expand Up @@ -358,7 +358,7 @@ export function createWorkerUploadForm(worker: CfWorkerInit): FormData {
metadataBindings.push({
name: binding,
type: "pipelines",
id: pipeline,
pipeline: pipeline,
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/wrangler/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ export async function mapBindings(
...(configObj.pipelines ?? []),
{
binding: binding.name,
pipeline: binding.id,
pipeline: binding.pipeline,
},
];
break;
Expand Down

0 comments on commit 3ee1353

Please sign in to comment.