Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MB -> MiB; GB -> GiB #1090

Merged
merged 2 commits into from May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/v2/providers/fixtures.ts
Expand Up @@ -4,7 +4,7 @@ import * as options from '../../../src/v2/options';

export const FULL_OPTIONS: options.GlobalOptions = {
region: 'us-west1',
memory: '512MB',
memory: '512MiB',
timeoutSeconds: 60,
minInstances: 1,
maxInstances: 3,
Expand Down
47 changes: 19 additions & 28 deletions src/v2/options.ts
Expand Up @@ -75,27 +75,27 @@ export const MAX_CONCURRENCY = 1_000;
* List of available memory options supported by Cloud Functions.
*/
export const SUPPORTED_MEMORY_OPTIONS = [
'128MB',
'256MB',
'512MB',
'1GB',
'2GB',
'4GB',
'8GB',
'16GB',
'32GB',
'128MiB',
'256MiB',
'512MiB',
'1GiB',
'2GiB',
'4GiB',
'8GiB',
'16GiB',
'32GiB',
] as const;

const MemoryOptionToMB: Record<MemoryOption, number> = {
'128MB': 128,
'256MB': 256,
'512MB': 512,
'1GB': 1024,
'2GB': 2048,
'4GB': 4096,
'8GB': 8192,
'16GB': 16384,
'32GB': 32768,
'128MiB': 128,
'256MiB': 256,
'512MiB': 512,
'1GiB': 1024,
'2GiB': 2048,
'4GiB': 4096,
'8GiB': 8192,
'16GiB': 16384,
'32GiB': 32768,
};

/**
Expand Down Expand Up @@ -340,16 +340,7 @@ export function optionsToEndpoint(
endpoint.vpc = vpc;
}
convertIfPresent(endpoint, opts, 'availableMemoryMb', 'memory', (mem) => {
const memoryLookup = {
'128MB': 128,
'256MB': 256,
'512MB': 512,
'1GB': 1024,
'2GB': 2048,
'4GB': 4096,
'8GB': 8192,
};
return memoryLookup[mem];
return MemoryOptionToMB[mem];
});
convertIfPresent(endpoint, opts, 'region', 'region', (region) => {
if (typeof region === 'string') {
Expand Down