Skip to content

Commit 27bc77f

Browse files
authored
MB -> MiB; GB -> GiB (#1090)
Change memory options to use the new V2 standard suffix that makes it clear we use base 2 units instead of base 10.
1 parent ea634a8 commit 27bc77f

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

spec/v2/providers/fixtures.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as options from '../../../src/v2/options';
44

55
export const FULL_OPTIONS: options.GlobalOptions = {
66
region: 'us-west1',
7-
memory: '512MB',
7+
memory: '512MiB',
88
timeoutSeconds: 60,
99
minInstances: 1,
1010
maxInstances: 3,

src/v2/options.ts

Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,27 @@ export const MAX_CONCURRENCY = 1_000;
7575
* List of available memory options supported by Cloud Functions.
7676
*/
7777
export const SUPPORTED_MEMORY_OPTIONS = [
78-
'128MB',
79-
'256MB',
80-
'512MB',
81-
'1GB',
82-
'2GB',
83-
'4GB',
84-
'8GB',
85-
'16GB',
86-
'32GB',
78+
'128MiB',
79+
'256MiB',
80+
'512MiB',
81+
'1GiB',
82+
'2GiB',
83+
'4GiB',
84+
'8GiB',
85+
'16GiB',
86+
'32GiB',
8787
] as const;
8888

8989
const MemoryOptionToMB: Record<MemoryOption, number> = {
90-
'128MB': 128,
91-
'256MB': 256,
92-
'512MB': 512,
93-
'1GB': 1024,
94-
'2GB': 2048,
95-
'4GB': 4096,
96-
'8GB': 8192,
97-
'16GB': 16384,
98-
'32GB': 32768,
90+
'128MiB': 128,
91+
'256MiB': 256,
92+
'512MiB': 512,
93+
'1GiB': 1024,
94+
'2GiB': 2048,
95+
'4GiB': 4096,
96+
'8GiB': 8192,
97+
'16GiB': 16384,
98+
'32GiB': 32768,
9999
};
100100

101101
/**
@@ -340,16 +340,7 @@ export function optionsToEndpoint(
340340
endpoint.vpc = vpc;
341341
}
342342
convertIfPresent(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
343-
const memoryLookup = {
344-
'128MB': 128,
345-
'256MB': 256,
346-
'512MB': 512,
347-
'1GB': 1024,
348-
'2GB': 2048,
349-
'4GB': 4096,
350-
'8GB': 8192,
351-
};
352-
return memoryLookup[mem];
343+
return MemoryOptionToMB[mem];
353344
});
354345
convertIfPresent(endpoint, opts, 'region', 'region', (region) => {
355346
if (typeof region === 'string') {

0 commit comments

Comments
 (0)