2017-09-19 14:47:10 +00:00
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
2020-06-11 21:23:00 +00:00
|
|
|
export default class ResourcesSerializer extends ApplicationSerializer {
|
2020-10-12 22:26:54 +00:00
|
|
|
arrayNullOverrides = ['Ports', 'Networks'];
|
|
|
|
|
|
|
|
normalize(typeHash, hash) {
|
|
|
|
hash.Cpu = hash.Cpu && hash.Cpu.CpuShares;
|
|
|
|
hash.Memory = hash.Memory && hash.Memory.MemoryMB;
|
|
|
|
hash.Disk = hash.Disk && hash.Disk.DiskMB;
|
|
|
|
|
|
|
|
// Networks for ReservedResources is different than for Resources.
|
|
|
|
// This smooths over the differences, but doesn't actually support
|
|
|
|
// anything in the ReservedResources.Networks object, since we don't
|
|
|
|
// use any of it in the UI.
|
|
|
|
if (!(hash.Networks instanceof Array)) {
|
|
|
|
hash.Networks = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.normalize(...arguments);
|
|
|
|
}
|
2020-06-11 21:23:00 +00:00
|
|
|
}
|