Skip to content

Commit 2f72c33

Browse files
leonLeon Radleyjoehan
authored
Add support for 4GB memory option (#842)
* Add support for 4GB memory option The 4GB memory option was not added everywhere. Fixes #834 * Added test for 4GB memory option Co-authored-by: Leon Radley <[email protected]> Co-authored-by: joehan <[email protected]>
1 parent 9b8fe65 commit 2f72c33

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

spec/function-builder.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,16 @@ describe('FunctionBuilder', () => {
286286
});
287287
}).to.throw();
288288
});
289+
290+
it('should allow setting 4GB memory option', () => {
291+
const fn = functions
292+
.runWith({
293+
memory: '4GB',
294+
})
295+
.region('europe-west1')
296+
.auth.user()
297+
.onCreate((user) => user);
298+
299+
expect(fn.__trigger.availableMemoryMb).to.deep.equal(4096);
300+
});
289301
});

src/cloud-functions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ export function optionsToTrigger(options: DeploymentOptions) {
507507
'512MB': 512,
508508
'1GB': 1024,
509509
'2GB': 2048,
510+
'4GB': 4096,
510511
};
511512
trigger.availableMemoryMb = _.get(memoryLookup, options.memory);
512513
}

src/function-builder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function region(
144144
* Configure runtime options for the function.
145145
* @param runtimeOptions Object with optional fields:
146146
* 1. `memory`: amount of memory to allocate to the function, possible values
147-
* are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
147+
* are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
148148
* 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
149149
* 0 to 540.
150150
* 3. `failurePolicy`: failure policy of the function, with boolean `true` being
@@ -188,7 +188,7 @@ export class FunctionBuilder {
188188
* Configure runtime options for the function.
189189
* @param runtimeOptions Object with optional fields:
190190
* 1. `memory`: amount of memory to allocate to the function, possible values
191-
* are: '128MB', '256MB', '512MB', '1GB', and '2GB'.
191+
* are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
192192
* 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
193193
* 0 to 540.
194194
* 3. `failurePolicy`: failure policy of the function, with boolean `true` being

0 commit comments

Comments
 (0)