style: static methods
This commit is contained in:
parent
c7938efd2f
commit
17def8e304
@ -675,7 +675,7 @@ class Data extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
_calcCurrentScale ({ config, currentVersion }, cb) {
|
||||
static _calcCurrentScale ({ config, currentVersion }, cb) {
|
||||
return config.map(({ name }) => {
|
||||
const currentScale = Find(ForceArray(currentVersion ? currentVersion.scale : []), [
|
||||
'serviceName',
|
||||
@ -696,7 +696,7 @@ class Data extends EventEmitter {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
this._calcCurrentScale({ config, currentVersion }, cb);
|
||||
Data._calcCurrentScale({ config, currentVersion }, cb);
|
||||
};
|
||||
|
||||
if (!this._triton) {
|
||||
@ -1534,7 +1534,7 @@ class Data extends EventEmitter {
|
||||
return Object.assign({}, branch, {
|
||||
instances: this._instancesFilter(branch.instances)
|
||||
});
|
||||
}).filter(({ name }) => name);
|
||||
}).filter(({ name }) => { return name; });
|
||||
|
||||
return cb(null, Transform.fromService({
|
||||
service,
|
||||
@ -1602,7 +1602,7 @@ class Data extends EventEmitter {
|
||||
return Object.assign({}, branch, {
|
||||
instances: this._instancesFilter(branch.instances)
|
||||
});
|
||||
}).filter(({ name }) => name);
|
||||
}).filter(({ name }) => { return name; });
|
||||
|
||||
return Transform.fromService({
|
||||
service,
|
||||
@ -2564,9 +2564,11 @@ class Data extends EventEmitter {
|
||||
metric.name = metricNameEnum[i];
|
||||
}
|
||||
|
||||
metric.metrics = metric.metrics.map((entry) => Object.assign(entry, {
|
||||
metric.metrics = metric.metrics.map((entry) => {
|
||||
return Object.assign(entry, {
|
||||
time: entry.time.toISOString()
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
return Object.assign(metric, {
|
||||
start: metric.metrics[0].time,
|
||||
@ -2587,7 +2589,7 @@ class Data extends EventEmitter {
|
||||
|
||||
prometheus.getMetrics({
|
||||
names: formattedNames,
|
||||
instances: ctx.machines.map(({ name }) => name),
|
||||
instances: ctx.machines.map(({ name }) => { return name; }),
|
||||
start,
|
||||
end
|
||||
}, (err, metrics) => {
|
||||
|
@ -311,7 +311,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
}, cb);
|
||||
}
|
||||
|
||||
_resolveServiceConnections ({ services, service }) {
|
||||
static _resolveServiceConnections ({ services, service }) {
|
||||
const watches = Uniq(
|
||||
Flatten(
|
||||
ForceArray(service.instances).map(({ watches }) => {
|
||||
@ -348,7 +348,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
});
|
||||
}
|
||||
|
||||
_resolveInstanceHealth ({ name }, instance) {
|
||||
static _resolveInstanceHealth ({ name }, instance) {
|
||||
if (!instance) {
|
||||
return 'UNAVAILABLE';
|
||||
}
|
||||
@ -379,7 +379,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
return 'UNKNOWN';
|
||||
}
|
||||
|
||||
_resolveServiceBranches ({ name, slug, instances }) {
|
||||
static _resolveServiceBranches ({ name, slug, instances }) {
|
||||
if (instances.length <= 1) {
|
||||
return [];
|
||||
}
|
||||
@ -437,7 +437,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
return Object.values(branches).concat(defaultBranch);
|
||||
}
|
||||
|
||||
_resolveDeploymentGroups (dgs) {
|
||||
static _resolveDeploymentGroups (dgs) {
|
||||
return dgs
|
||||
.filter(Boolean)
|
||||
.map((dg) => {
|
||||
@ -451,7 +451,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
});
|
||||
|
||||
return Object.assign({}, instance, {
|
||||
healthy: this._resolveInstanceHealth(service, instance),
|
||||
healthy: ContainerPilotWatcher._resolveInstanceHealth(service, instance),
|
||||
jobs,
|
||||
watches
|
||||
});
|
||||
@ -464,8 +464,8 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
return Object.assign({}, dg, {
|
||||
services: ForceArray(dg.services).map((service) => {
|
||||
return Object.assign({}, service, {
|
||||
branches: this._resolveServiceBranches(service),
|
||||
connections: this._resolveServiceConnections({
|
||||
branches: ContainerPilotWatcher._resolveServiceBranches(service),
|
||||
connections: ContainerPilotWatcher._resolveServiceConnections({
|
||||
services: dg.services,
|
||||
service
|
||||
})
|
||||
@ -485,7 +485,7 @@ module.exports = class ContainerPilotWatcher extends Events {
|
||||
this.emit('error', err);
|
||||
}
|
||||
|
||||
const dgs = this._resolveDeploymentGroups(
|
||||
const dgs = ContainerPilotWatcher._resolveDeploymentGroups(
|
||||
ForceArray((results || {}).successes)
|
||||
);
|
||||
|
||||
|
@ -141,7 +141,7 @@ module.exports = class MachineWatcher {
|
||||
});
|
||||
}
|
||||
|
||||
getInstances (service, cb) {
|
||||
static getInstances (service, cb) {
|
||||
service.instances()
|
||||
.then((instances) => {
|
||||
return cb(null, instances);
|
||||
@ -151,7 +151,7 @@ module.exports = class MachineWatcher {
|
||||
});
|
||||
}
|
||||
|
||||
getVersion (deploymentGroup, cb) {
|
||||
static getVersion (deploymentGroup, cb) {
|
||||
if (typeof deploymentGroup.version !== 'function') {
|
||||
return cb(new Error('version must be a function'));
|
||||
}
|
||||
@ -578,12 +578,12 @@ module.exports = class MachineWatcher {
|
||||
service,
|
||||
deploymentGroup
|
||||
}, cb) => {
|
||||
this.getInstances(service, (err, instances = []) => {
|
||||
MachineWatcher.getInstances(service, (err, instances = []) => {
|
||||
if (err && !isNotFound(err)) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
this.getVersion(deploymentGroup, (err, version) => {
|
||||
MachineWatcher.getVersion(deploymentGroup, (err, version) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ describe('graphql', () => {
|
||||
|
||||
server.inject({ method: 'POST', url: '/graphql', payload }, (res) => {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
console.log(res.result.data)
|
||||
console.log(res.result.data);
|
||||
const deploymentGroup = res.result.data.portal.deploymentGroups[0];
|
||||
expect(deploymentGroup.name).to.equal('test');
|
||||
expect(deploymentGroup.services[0].name).to.equal('service');
|
||||
|
Loading…
Reference in New Issue
Block a user