Skip to content

Commit b6e611b

Browse files
authored
Adds newly available GCF regions. (#722)
1 parent 5f7c7ac commit b6e611b

File tree

5 files changed

+18
-38
lines changed

5 files changed

+18
-38
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
- Fixes error when last argument to logger methods is `null`. (#716)
2+
- Adds newly available locations `us-west3`, `europe-west6`, `northamerica-northeast1`, and `australia-southeast1`.
3+
- No longer throw errors for unrecognized regions (deploy will error instead).

scripts/fetch-regions

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
if [ -z $1 ]; then
4+
echo "Must provide a project id as first argument." && exit 1
5+
fi;
6+
7+
gcloud functions regions list --project $1 --format=json | jq 'map(.locationId)'

spec/function-builder.spec.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,6 @@ describe('FunctionBuilder', () => {
121121
expect(fn.__trigger.timeout).to.deep.equal('90s');
122122
});
123123

124-
it('should fail if valid runtime options but unsupported region are set (reverse order)', () => {
125-
expect(() => {
126-
functions
127-
.runWith({ timeoutSeconds: 90, memory: '256MB' })
128-
.region('unsupported' as any);
129-
}).to.throw(Error, 'region');
130-
});
131-
132124
it('should fail if supported region but invalid runtime options are set (reverse order)', () => {
133125
expect(() => {
134126
functions
@@ -165,28 +157,6 @@ describe('FunctionBuilder', () => {
165157
}).to.throw(Error, 'TimeoutSeconds');
166158
});
167159

168-
it('should throw an error if user chooses an invalid region', () => {
169-
expect(() => {
170-
return functions.region('unsupported' as any);
171-
}).to.throw(Error, 'region');
172-
173-
expect(() => {
174-
return functions.region('unsupported' as any).runWith({
175-
timeoutSeconds: 500,
176-
} as any);
177-
}).to.throw(Error, 'region');
178-
179-
expect(() => {
180-
return functions.region('unsupported' as any, 'us-east1');
181-
}).to.throw(Error, 'region');
182-
183-
expect(() => {
184-
return functions.region('unsupported' as any, 'us-east1').runWith({
185-
timeoutSeconds: 500,
186-
} as any);
187-
}).to.throw(Error, 'region');
188-
});
189-
190160
it('should throw an error if user chooses no region when using .region()', () => {
191161
expect(() => {
192162
return functions.region();

src/function-builder.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ function assertRegionsAreValid(regions: string[]): boolean {
7878
if (!regions.length) {
7979
throw new Error('You must specify at least one region');
8080
}
81-
if (_.difference(regions, SUPPORTED_REGIONS).length) {
82-
throw new Error(
83-
`The only valid regions are: ${SUPPORTED_REGIONS.join(', ')}`
84-
);
85-
}
8681
return true;
8782
}
8883

@@ -95,7 +90,7 @@ function assertRegionsAreValid(regions: string[]): boolean {
9590
* functions.region('us-east1', 'us-central1')
9691
*/
9792
export function region(
98-
...regions: Array<typeof SUPPORTED_REGIONS[number]>
93+
...regions: Array<typeof SUPPORTED_REGIONS[number] | string>
9994
): FunctionBuilder {
10095
if (assertRegionsAreValid(regions)) {
10196
return new FunctionBuilder({ regions });
@@ -127,7 +122,9 @@ export class FunctionBuilder {
127122
* @example
128123
* functions.region('us-east1', 'us-central1')
129124
*/
130-
region(...regions: Array<typeof SUPPORTED_REGIONS[number]>): FunctionBuilder {
125+
region(
126+
...regions: Array<typeof SUPPORTED_REGIONS[number] | string>
127+
): FunctionBuilder {
131128
if (assertRegionsAreValid(regions)) {
132129
this.options.regions = regions;
133130
return this;

src/function-configuration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ export const SUPPORTED_REGIONS = [
55
'us-central1',
66
'us-east1',
77
'us-east4',
8+
'us-west3',
89
'europe-west1',
910
'europe-west2',
1011
'europe-west3',
12+
'europe-west6',
1113
'asia-east2',
1214
'asia-northeast1',
15+
'northamerica-northeast1',
16+
'australia-southeast1',
1317
] as const;
1418

1519
/**
@@ -70,6 +74,6 @@ export interface RuntimeOptions {
7074
}
7175

7276
export interface DeploymentOptions extends RuntimeOptions {
73-
regions?: Array<typeof SUPPORTED_REGIONS[number]>;
77+
regions?: Array<typeof SUPPORTED_REGIONS[number] | string>;
7478
schedule?: Schedule;
7579
}

0 commit comments

Comments
 (0)