(imageMetadata: ImageMetadataEntry[])
| 210 | } |
| 211 | |
| 212 | function 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 | |
| 225 | function 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 |
no test coverage detected