Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Pipelines to use name instead of id #7134

Merged
merged 3 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading