MCPcopy Create free account
hub / github.com/devcontainers/cli / mergeHostRequirements

Function mergeHostRequirements

src/spec-node/imageMetadata.ts:212–223  ·  view source on GitHub ↗
(imageMetadata: ImageMetadataEntry[])

Source from the content-addressed store, hash-verified

210}
211
212function mergeHostRequirements(imageMetadata: ImageMetadataEntry[]) {
213 const cpus = Math.max(...imageMetadata.map(m => m.hostRequirements?.cpus || 0));
214 const memory = Math.max(...imageMetadata.map(m => parseBytes(m.hostRequirements?.memory || '0')));
215 const storage = Math.max(...imageMetadata.map(m => parseBytes(m.hostRequirements?.storage || '0')));
216 const gpu = imageMetadata.map(m => m.hostRequirements?.gpu).reduce(mergeGpuRequirements, undefined);
217 return cpus || memory || storage || gpu ? {
218 cpus,
219 memory: memory ? `${memory}` : undefined,
220 storage: storage ? `${storage}` : undefined,
221 gpu: gpu,
222 } : undefined;
223}
224
225function mergeGpuRequirements(a: undefined | boolean | 'optional' | HostGPURequirements, b: undefined | boolean | 'optional' | HostGPURequirements): undefined | boolean | 'optional' | HostGPURequirements {
226 // simple cases if either are undefined/false we use the other one

Callers 1

mergeConfigurationFunction · 0.85

Calls 1

parseBytesFunction · 0.85

Tested by

no test coverage detected