mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 06:00:06 +02:00
feat(portal-api): add branches resolver
This commit is contained in:
parent
9802bba502
commit
09ae91af93
@ -1359,6 +1359,11 @@ class Data extends EventEmitter {
|
|||||||
|
|
||||||
return cb(null, Transform.fromService({
|
return cb(null, Transform.fromService({
|
||||||
service,
|
service,
|
||||||
|
branches: service.branches.map((service) => {
|
||||||
|
return Object.assign({}, service, {
|
||||||
|
instances: this._instancesFilter(service.instances)
|
||||||
|
});
|
||||||
|
}),
|
||||||
instances: this._instancesFilter(service.instance_ids)
|
instances: this._instancesFilter(service.instance_ids)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -1,30 +1,36 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
const FindIndex = require('lodash.findindex');
|
const FindIndex = require('lodash.findindex');
|
||||||
|
|
||||||
module.exports = ({ deploymentGroups = [], services = [], instances = [] }) => {
|
module.exports = ({ deploymentGroups = [], services = [], instances = [] }) => {
|
||||||
const getInstances = serviceId => (opts, cb) => {
|
const getInstances = (serviceId) => {
|
||||||
cb(null, instances
|
return (opts, cb) => {
|
||||||
.filter(instance => {
|
cb(null, instances
|
||||||
|
.filter((instance) => {
|
||||||
return instance.serviceId === serviceId;
|
return instance.serviceId === serviceId;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getServices = deploymentGroupId => (opts, cb) => {
|
const getServices = (deploymentGroupId) => {
|
||||||
cb(null, services
|
return (opts, cb) => {
|
||||||
.filter(service => {
|
cb(null, services
|
||||||
|
.filter((service) => {
|
||||||
return service.deploymentGroupId === deploymentGroupId;
|
return service.deploymentGroupId === deploymentGroupId;
|
||||||
})
|
})
|
||||||
.map(service => {
|
.map((service) => {
|
||||||
return Object.assign({}, service, {
|
return Object.assign({}, service, {
|
||||||
instances: getInstances(service.id)
|
instances: getInstances(service.id)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDeploymentGroups = (opts, cb) => {
|
const getDeploymentGroups = (opts, cb) => {
|
||||||
cb(null, deploymentGroups
|
cb(null, deploymentGroups
|
||||||
.map(dg => {
|
.map((dg) => {
|
||||||
return Object.assign({}, dg, {
|
return Object.assign({}, dg, {
|
||||||
services: getServices(dg.id)
|
services: getServices(dg.id)
|
||||||
});
|
});
|
||||||
@ -54,8 +60,8 @@ module.exports = ({ deploymentGroups = [], services = [], instances = [] }) => {
|
|||||||
const serviceIndex = FindIndex(service, ['id', service.id]);
|
const serviceIndex = FindIndex(service, ['id', service.id]);
|
||||||
const updatedService = Object.assign({}, services[serviceIndex], service);
|
const updatedService = Object.assign({}, services[serviceIndex], service);
|
||||||
|
|
||||||
services[serviceIndex] = updateService;
|
services[serviceIndex] = updatedService;
|
||||||
return updateService;
|
return updatedService;
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
const Find = require('lodash.find');
|
const Find = require('lodash.find');
|
||||||
|
|
||||||
module.exports = ({ machines = [], networks = [] }) => {
|
module.exports = ({ machines = [], networks = [] }) => {
|
||||||
|
@ -10,7 +10,7 @@ const TritonMock = require('../_mocks/triton');
|
|||||||
|
|
||||||
const lab = exports.lab = Lab.script();
|
const lab = exports.lab = Lab.script();
|
||||||
const it = lab.it;
|
const it = lab.it;
|
||||||
const expect = Lab.expect;
|
// const expect = Lab.expect;
|
||||||
|
|
||||||
|
|
||||||
it('sets instance health statuses appropriately', (done) => {
|
it('sets instance health statuses appropriately', (done) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user