diff --git a/ui/mirage/common.js b/ui/mirage/common.js index 45508c5c9..acfd6069d 100644 --- a/ui/mirage/common.js +++ b/ui/mirage/common.js @@ -27,10 +27,10 @@ export const STORAGE_PROVIDERS = ['ebs', 'zfs', 'nfs', 'cow', 'moo']; export function generateResources(options = {}) { return { - CPU: faker.helpers.randomize(CPU_RESERVATIONS), - MemoryMB: faker.helpers.randomize(MEMORY_RESERVATIONS), - DiskMB: faker.helpers.randomize(DISK_RESERVATIONS), - IOPS: faker.helpers.randomize(IOPS_RESERVATIONS), + CPU: options.CPU || faker.helpers.randomize(CPU_RESERVATIONS), + MemoryMB: options.MemoryMB || faker.helpers.randomize(MEMORY_RESERVATIONS), + DiskMB: options.DiskMB || faker.helpers.randomize(DISK_RESERVATIONS), + IOPS: options.IOPS || faker.helpers.randomize(IOPS_RESERVATIONS), Networks: generateNetworks(options.networks), Ports: generatePorts(options.networks), }; @@ -73,15 +73,17 @@ export function generateNetworks(options = {}) { } export function generatePorts(options = {}) { - return Array(faker.random.number({ - min: options.minPorts != null ? options.minPorts : 0, - max: options.maxPorts != null ? options.maxPorts : 2 - })) + return Array( + faker.random.number({ + min: options.minPorts != null ? options.minPorts : 0, + max: options.maxPorts != null ? options.maxPorts : 2, + }) + ) .fill(null) .map(() => ({ Label: faker.hacker.noun(), Value: faker.random.number({ min: 5000, max: 60000 }), To: faker.random.number({ min: 5000, max: 60000 }), HostIP: faker.random.boolean() ? faker.internet.ip() : faker.internet.ipv6(), - })) -} \ No newline at end of file + })); +}