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({
|
||||
service,
|
||||
branches: service.branches.map((service) => {
|
||||
return Object.assign({}, service, {
|
||||
instances: this._instancesFilter(service.instances)
|
||||
});
|
||||
}),
|
||||
instances: this._instancesFilter(service.instance_ids)
|
||||
}));
|
||||
});
|
||||
|
@ -1,30 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
const FindIndex = require('lodash.findindex');
|
||||
|
||||
module.exports = ({ deploymentGroups = [], services = [], instances = [] }) => {
|
||||
const getInstances = serviceId => (opts, cb) => {
|
||||
cb(null, instances
|
||||
.filter(instance => {
|
||||
const getInstances = (serviceId) => {
|
||||
return (opts, cb) => {
|
||||
cb(null, instances
|
||||
.filter((instance) => {
|
||||
return instance.serviceId === serviceId;
|
||||
})
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const getServices = deploymentGroupId => (opts, cb) => {
|
||||
cb(null, services
|
||||
.filter(service => {
|
||||
const getServices = (deploymentGroupId) => {
|
||||
return (opts, cb) => {
|
||||
cb(null, services
|
||||
.filter((service) => {
|
||||
return service.deploymentGroupId === deploymentGroupId;
|
||||
})
|
||||
.map(service => {
|
||||
.map((service) => {
|
||||
return Object.assign({}, service, {
|
||||
instances: getInstances(service.id)
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const getDeploymentGroups = (opts, cb) => {
|
||||
cb(null, deploymentGroups
|
||||
.map(dg => {
|
||||
.map((dg) => {
|
||||
return Object.assign({}, dg, {
|
||||
services: getServices(dg.id)
|
||||
});
|
||||
@ -54,8 +60,8 @@ module.exports = ({ deploymentGroups = [], services = [], instances = [] }) => {
|
||||
const serviceIndex = FindIndex(service, ['id', service.id]);
|
||||
const updatedService = Object.assign({}, services[serviceIndex], service);
|
||||
|
||||
services[serviceIndex] = updateService;
|
||||
return updateService;
|
||||
services[serviceIndex] = updatedService;
|
||||
return updatedService;
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const Find = require('lodash.find');
|
||||
|
||||
module.exports = ({ machines = [], networks = [] }) => {
|
||||
|
@ -10,7 +10,7 @@ const TritonMock = require('../_mocks/triton');
|
||||
|
||||
const lab = exports.lab = Lab.script();
|
||||
const it = lab.it;
|
||||
const expect = Lab.expect;
|
||||
// const expect = Lab.expect;
|
||||
|
||||
|
||||
it('sets instance health statuses appropriately', (done) => {
|
||||
|
Loading…
Reference in New Issue
Block a user