Skip to content

Commit 4193029

Browse files
authored
Revert "allow Expressions in the top-level configuration of v1 functions (#1249)" (#1252)
This reverts commit 9332ea0.
1 parent 9332ea0 commit 4193029

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

src/v1/cloud-functions.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { DeploymentOptions } from "./function-configuration";
2626
export { Request, Response };
2727
import { convertIfPresent, copyIfPresent } from "../common/encoding";
2828
import { ManifestEndpoint, ManifestRequiredAPI } from "../runtime/manifest";
29-
import { Expression } from "../params";
3029

3130
export { Change } from "../common/change";
3231

@@ -476,26 +475,17 @@ export function optionsToEndpoint(options: DeploymentOptions): ManifestEndpoint
476475
endpoint.vpc = { connector: options.vpcConnector };
477476
convertIfPresent(endpoint.vpc, options, "egressSettings", "vpcConnectorEgressSettings");
478477
}
479-
convertIfPresent(
480-
endpoint,
481-
options,
482-
"availableMemoryMb",
483-
"memory",
484-
(mem: string | Expression<number>) => {
485-
if (typeof mem === "string") {
486-
const memoryLookup = {
487-
"128MB": 128,
488-
"256MB": 256,
489-
"512MB": 512,
490-
"1GB": 1024,
491-
"2GB": 2048,
492-
"4GB": 4096,
493-
"8GB": 8192,
494-
};
495-
return memoryLookup[mem];
496-
}
497-
return mem;
498-
}
499-
);
478+
convertIfPresent(endpoint, options, "availableMemoryMb", "memory", (mem) => {
479+
const memoryLookup = {
480+
"128MB": 128,
481+
"256MB": 256,
482+
"512MB": 512,
483+
"1GB": 1024,
484+
"2GB": 2048,
485+
"4GB": 4096,
486+
"8GB": 8192,
487+
};
488+
return memoryLookup[mem];
489+
});
500490
return endpoint;
501491
}

src/v1/function-builder.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ import * as testLab from "./providers/testLab";
5050
* @throws { Error } Memory and TimeoutSeconds values must be valid.
5151
*/
5252
function assertRuntimeOptionsValid(runtimeOptions: RuntimeOptions): boolean {
53-
if (
54-
runtimeOptions.memory &&
55-
typeof runtimeOptions.memory === "string" &&
56-
!VALID_MEMORY_OPTIONS.includes(runtimeOptions.memory)
57-
) {
53+
if (runtimeOptions.memory && !VALID_MEMORY_OPTIONS.includes(runtimeOptions.memory)) {
5854
throw new Error(
5955
`The only valid memory allocation values are: ${VALID_MEMORY_OPTIONS.join(", ")}`
6056
);

src/v1/function-configuration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,23 @@ export interface RuntimeOptions {
174174
/**
175175
* Amount of memory to allocate to the function.
176176
*/
177-
memory?: typeof VALID_MEMORY_OPTIONS[number] | Expression<number>;
177+
memory?: typeof VALID_MEMORY_OPTIONS[number];
178178
/**
179179
* Timeout for the function in seconds, possible values are 0 to 540.
180180
*/
181-
timeoutSeconds?: number | Expression<number>;
181+
timeoutSeconds?: number;
182182

183183
/**
184184
* Min number of actual instances to be running at a given time.
185185
* Instances will be billed for memory allocation and 10% of CPU allocation
186186
* while idle.
187187
*/
188-
minInstances?: number | Expression<number>;
188+
minInstances?: number;
189189

190190
/**
191191
* Max number of actual instances allowed to be running in parallel.
192192
*/
193-
maxInstances?: number | Expression<number>;
193+
maxInstances?: number;
194194

195195
/**
196196
* Connect cloud function to specified VPC connector.

0 commit comments

Comments
 (0)