github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/mirage/factories/service-fragment.js (about)

     1  import { Factory } from 'ember-cli-mirage';
     2  import faker from 'nomad-ui/mirage/faker';
     3  import { provide } from '../utils';
     4  import { dasherize } from '@ember/string';
     5  import { pickOne } from '../utils';
     6  
     7  const ON_UPDATE = ['default', 'ignore', 'ignore_warnings'];
     8  
     9  export default Factory.extend({
    10    name: (id) => `${dasherize(faker.hacker.noun())}-${id}-service`,
    11    portLabel: () => dasherize(faker.hacker.noun()),
    12    onUpdate: faker.helpers.randomize(ON_UPDATE),
    13    provider: () => pickOne(['nomad', 'consul']),
    14    tags: () => {
    15      if (!faker.random.boolean()) {
    16        return provide(
    17          faker.random.number({ min: 0, max: 2 }),
    18          faker.hacker.noun.bind(faker.hacker.noun)
    19        );
    20      } else {
    21        return null;
    22      }
    23    },
    24    Connect: {
    25      SidecarService: {
    26        Proxy: {
    27          Upstreams: [
    28            {
    29              DestinationName: dasherize(faker.hacker.noun()),
    30              LocalBindPort: faker.random.number({ min: 5000, max: 60000 }),
    31            },
    32          ],
    33        },
    34      },
    35    },
    36  });