Skip to content

Commit 7e3aa1b

Browse files
authored
CFSQL-1261: remove the need for d1 to patch wrangler for testing (#9748)
* CFSQL-1261: Let D1 team stop patching wrangler for testing * CFSQL-1261: add changeset
1 parent 1358034 commit 7e3aa1b

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

.changeset/wild-books-search.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+
Internal-only WRANGLER_D1_EXTRA_LOCATION_CHOICES environment variable for enabling D1's testing location hints

packages/wrangler/src/d1/create.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import dedent from "ts-dedent";
22
import { fetchResult } from "../cfetch";
33
import { formatConfigSnippet } from "../config";
44
import { createCommand } from "../core/create-command";
5+
import { getD1ExtraLocationChoices } from "../environment-variables/misc-variables";
56
import { UserError } from "../errors";
67
import { logger } from "../logger";
78
import { requireAuth } from "../user";
@@ -53,7 +54,10 @@ export const d1CreateCommand = createCommand({
5354
},
5455
location: {
5556
type: "string",
56-
choices: LOCATION_CHOICES,
57+
choices: [
58+
...LOCATION_CHOICES,
59+
...(getD1ExtraLocationChoices()?.split(",") ?? []),
60+
],
5761
description: dedent`
5862
A hint for the primary location of the new DB. Options:
5963
weur: Western Europe

packages/wrangler/src/environment-variables/factory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ type VariableNames =
3333
| "WRANGLER_BUILD_CONDITIONS"
3434
| "WRANGLER_BUILD_PLATFORM"
3535
| "WRANGLER_REGISTRY_PATH"
36+
| "WRANGLER_D1_EXTRA_LOCATION_CHOICES"
3637
| "WRANGLER_DOCKER_BIN"
3738
| "WRANGLER_DOCKER_HOST";
3839

packages/wrangler/src/environment-variables/misc-variables.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ export const getRegistryPath = getEnvironmentVariableFactory({
248248
},
249249
});
250250

251+
/**
252+
* `WRANGLER_D1_EXTRA_LOCATION_CHOICES` is an internal variable to let D1 team target their testing environments.
253+
*
254+
* External accounts cannot access testing envionments, so should not set this variable.
255+
*/
256+
export const getD1ExtraLocationChoices: () => string | undefined =
257+
getEnvironmentVariableFactory({
258+
variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES",
259+
});
260+
251261
/**
252262
* `WRANGLER_DOCKER_BIN` specifies the path to a docker binary.
253263
*

packages/wrangler/turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"WORKERS_CI",
4646
"WRANGLER_API_ENVIRONMENT",
4747
"WRANGLER_AUTH_DOMAIN",
48+
"WRANGLER_D1_EXTRA_LOCATION_CHOICES",
4849
"WRANGLER_DISABLE_EXPERIMENTAL_WARNING",
4950
"WRANGLER_DISABLE_REQUEST_BODY_DRAINING",
5051
"WRANGLER_LOG",

0 commit comments

Comments
 (0)