e03c5a43be
* Added to subnav and basic table implemented * Existing services become service fragments, and services tab aggregated beneath job route * Index page within jobs/job/services * Watchable services * Lintfixes * Links to clients and individual services set up * Child service route * Keyboard shortcuts on service page * Model that shows consul services as well, plus level and provider cols * lintfix * Level as query param * Watch job for service name changes too * Group level service fixtures established * Progress at task level and job-linked services * Task and group services on update * Fixture side-effect cleanup * Basic acceptance tests for job services * Testmodel cleanup * Disabled mirage logging * New cluster type specifically for services * Without explicit job-model binding * Trying to isolate a tostring error * Account for new tab in keyboardnav * More test isolation attempts * Remove skipped tests and link task to parent group by id ui: add service health viz to table (#14369) * ui: add service-status-bar * test: service-status-bar * refact: update component api for new data struct * ui: format service health struct * ui: add service health viz to table * temp: add placeholder to remind conditional watcher * test: write tests for transformation algorithm * refact: update transformation algo * ui: conditionally long poll checks endpoint * refact: add conditional logic for nomad provider refact: update service-fragment model to include owner info ui: differentiate between task and group-level in derived state comp test: add test to document behavior refact: update tests for api change refact: update integration test for API change chore: remove unsused vars chore: elvis operator to protect mirage refact: create refId instead of internalModel refact: update algo refact: update conditional template logic refact: update test for api change: chore: cant use if and not in hbs conditional
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
import { Factory } from 'ember-cli-mirage';
|
|
import faker from 'nomad-ui/mirage/faker';
|
|
import { provide } from '../utils';
|
|
import { dasherize } from '@ember/string';
|
|
import { DATACENTERS } from '../common';
|
|
import { pickOne } from '../utils';
|
|
|
|
export default Factory.extend({
|
|
id: () => faker.random.uuid(),
|
|
address: () => faker.internet.ip(),
|
|
createIndex: () => faker.random.number(),
|
|
modifyIndex: () => faker.random.number(),
|
|
name: () => faker.random.uuid(),
|
|
serviceName: (id) => `${dasherize(faker.hacker.noun())}-${id}-service`,
|
|
datacenter: faker.helpers.randomize(DATACENTERS),
|
|
port: faker.random.number({ min: 5000, max: 60000 }),
|
|
tags: () => {
|
|
if (!faker.random.boolean()) {
|
|
return provide(
|
|
faker.random.number({ min: 0, max: 2 }),
|
|
faker.hacker.noun.bind(faker.hacker.noun)
|
|
);
|
|
} else {
|
|
return null;
|
|
}
|
|
},
|
|
|
|
afterCreate(service, server) {
|
|
if (!service.namespace) {
|
|
const namespace = pickOne(server.db.jobs)?.namespace || 'default';
|
|
service.update({
|
|
namespace,
|
|
});
|
|
}
|
|
|
|
if (!service.node) {
|
|
const node = pickOne(server.db.nodes);
|
|
service.update({
|
|
nodeId: node.id,
|
|
});
|
|
}
|
|
|
|
if (server.db.jobs.findBy({ id: 'service-haver' })) {
|
|
if (!service.jobId) {
|
|
service.update({
|
|
jobId: 'service-haver',
|
|
});
|
|
}
|
|
if (!service.allocId) {
|
|
const servicedAlloc = pickOne(
|
|
server.db.allocations.filter((a) => a.jobId === 'service-haver') || []
|
|
);
|
|
if (servicedAlloc) {
|
|
service.update({
|
|
allocId: servicedAlloc.id,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
},
|
|
});
|