github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/mirage/factories/agent.js (about) 1 import { Factory } from 'ember-cli-mirage'; 2 import faker from 'nomad-ui/mirage/faker'; 3 import { provide } from '../utils'; 4 import { DATACENTERS } from '../common'; 5 6 const UUIDS = provide(100, faker.random.uuid.bind(faker.random)); 7 const AGENT_STATUSES = ['alive', 'leaving', 'left', 'failed']; 8 9 export default Factory.extend({ 10 id: i => (i / 100 >= 1 ? `${UUIDS[i]}-${i}` : UUIDS[i]), 11 name: () => `nomad@${faker.internet.ip()}`, 12 13 status: () => faker.helpers.randomize(AGENT_STATUSES), 14 serf_port: () => faker.random.number({ min: 4000, max: 4999 }), 15 16 address() { 17 return this.name.split('@')[1]; 18 }, 19 20 tags() { 21 const rpcPortCandidate = faker.random.number({ min: 4000, max: 4999 }); 22 return { 23 port: rpcPortCandidate === this.serf_port ? rpcPortCandidate + 1 : rpcPortCandidate, 24 dc: faker.helpers.randomize(DATACENTERS), 25 }; 26 }, 27 });