Skip to content

Commit 29015e5

Browse files
authored
Allow users to specify none to remove transformation (#8579)
`wrangler pipelines update <name> --transforms none` Fixes https://jira.cfdata.org/browse/PIPE-232
1 parent 18fa891 commit 29015e5

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

.changeset/warm-forks-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Allow `wrangler pipelines update <pipelineName> --transform-worker none` to remove transformations from a Pipeline.

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,25 @@ describe("pipelines", () => {
601601
`);
602602
expect(requests.count).toEqual(1);
603603
});
604+
605+
it("should remove transformations", async () => {
606+
const pipeline: Pipeline = samplePipeline;
607+
mockShowRequest(pipeline.name, pipeline);
608+
609+
const update = JSON.parse(JSON.stringify(pipeline));
610+
update.transforms = [
611+
{
612+
script: "hello",
613+
entrypoint: "MyTransform",
614+
},
615+
];
616+
const updateReq = mockUpdateRequest(update.name, update);
617+
618+
await runWrangler("pipelines update my-pipeline --transform-worker none");
619+
620+
expect(updateReq.count).toEqual(1);
621+
expect(updateReq.body?.transforms.length).toEqual(0);
622+
});
604623
});
605624

606625
describe("delete", () => {

packages/wrangler/src/pipelines/cli/update.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function addUpdateOptions(yargs: Argv<CommonYargsOptions>) {
104104
.option("transform-worker", {
105105
type: "string",
106106
describe:
107-
"Pipeline transform Worker and entrypoint (<worker>.<entrypoint>)",
107+
'Pipeline transform Worker and entrypoint, to transform ingested records. Specified as <worker-name>.<entrypoint>, or "none".',
108108
demandOption: false,
109109
})
110110

@@ -282,7 +282,12 @@ export async function updatePipelineHandler(
282282
}
283283

284284
if (args.transformWorker) {
285-
pipelineConfig.transforms.push(parseTransform(args.transformWorker));
285+
if (args.transformWorker === "none") {
286+
// Unset transformations
287+
pipelineConfig.transforms = [];
288+
} else {
289+
pipelineConfig.transforms.push(parseTransform(args.transformWorker));
290+
}
286291
}
287292

288293
if (args.r2Prefix) {

0 commit comments

Comments
 (0)