Skip to content

Commit 5e44242

Browse files
committed
Add confirmation for removing custom domain from R2 bucket
1 parent 98976f2 commit 5e44242

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1581,7 +1581,7 @@ describe("r2", () => {
15811581
)
15821582
);
15831583
await runWrangler(
1584-
`r2 bucket domain remove ${bucketName} --domain ${domainName}`
1584+
`r2 bucket domain remove ${bucketName} --domain ${domainName} --force`
15851585
);
15861586
expect(std.out).toMatchInlineSnapshot(`
15871587
"Removing custom domain 'example.com' from bucket 'my-bucket'...

packages/wrangler/src/r2/domain.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readConfig } from "../config";
2+
import { confirm } from "../dialogs";
23
import { logger } from "../logger";
34
import { printWranglerBanner } from "../update-check";
45
import { requireAuth } from "../user";
@@ -142,6 +143,12 @@ export function RemoveOptions(yargs: CommonYargsArgv) {
142143
alias: "J",
143144
requiresArg: true,
144145
type: "string",
146+
})
147+
.option("force", {
148+
describe: "Skip confirmation",
149+
type: "boolean",
150+
alias: "y",
151+
default: false,
145152
});
146153
}
147154

@@ -152,8 +159,17 @@ export async function RemoveHandler(
152159
const config = readConfig(args.config, args);
153160
const accountId = await requireAuth(config);
154161

155-
const { bucket, domain, jurisdiction } = args;
162+
const { bucket, domain, jurisdiction, force } = args;
156163

164+
if (!force) {
165+
const confirmedRemoval = await confirm(
166+
`Are you sure you want to remove the custom domain '${domain}' from bucket '${bucket}'? Your bucket will no longer be available from 'https://${domain}'`
167+
);
168+
if (!confirmedRemoval) {
169+
logger.log("Removal cancelled.");
170+
return;
171+
}
172+
}
157173
logger.log(`Removing custom domain '${domain}' from bucket '${bucket}'...`);
158174

159175
await removeCustomDomainFromBucket(accountId, bucket, domain, jurisdiction);

0 commit comments

Comments
 (0)