github.com/hernad/nomad@v1.6.112/ui/mirage/factories/scale-event.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { Factory, trait } from 'ember-cli-mirage';
     7  import faker from 'nomad-ui/mirage/faker';
     8  
     9  const REF_TIME = new Date();
    10  
    11  export default Factory.extend({
    12    time: () => faker.date.past(2 / 365, REF_TIME) * 1000000,
    13    count: () => faker.random.number(10),
    14    previousCount: () => faker.random.number(10),
    15    error: () => faker.random.number(10) > 8,
    16    message: 'Sample message for a job scale event',
    17    meta: () =>
    18      faker.random.number(10) < 8
    19        ? {
    20            'nomad_autoscaler.count.capped': true,
    21            'nomad_autoscaler.count.original': 0,
    22            'nomad_autoscaler.reason_history': ['scaling down because factor is 0.000000'],
    23          }
    24        : {},
    25  
    26    afterCreate(scaleEvent) {
    27      if (scaleEvent.error) {
    28        scaleEvent.update({ count: null });
    29      }
    30    },
    31  });