open-nomad/ui/mirage/factories/task.js

33 lines
775 B
JavaScript
Raw Normal View History

2019-09-26 18:47:07 +00:00
import { Factory } from 'ember-cli-mirage';
import faker from 'nomad-ui/mirage/faker';
2017-09-19 14:47:10 +00:00
import { generateResources } from '../common';
const DRIVERS = ['docker', 'java', 'rkt', 'qemu', 'exec', 'raw_exec'];
2017-09-19 14:47:10 +00:00
export default Factory.extend({
// Hidden property used to compute the Summary hash
groupNames: [],
// Set in the TaskGroup factory
volumeMounts: [],
2017-09-19 14:47:10 +00:00
JobID: '',
name: id => `task-${faker.hacker.noun().dasherize()}-${id}`,
driver: () => faker.helpers.randomize(DRIVERS),
2017-09-19 14:47:10 +00:00
Resources: generateResources,
Lifecycle: i => {
const cycle = i % 3;
if (cycle === 0) {
return null;
} else if (cycle === 1) {
return { Hook: 'prestart', Sidecar: false };
} else {
return { Hook: 'prestart', Sidecar: true };
}
},
2017-09-19 14:47:10 +00:00
});