feat(portal-api): properly expose branches

This commit is contained in:
Sérgio Ramos 2017-07-19 16:58:30 +01:00 committed by Judit Greskovits
parent fdb24ebc13
commit 4d8f6a1d4f
3 changed files with 26 additions and 9 deletions

View File

@ -1455,13 +1455,15 @@ class Data extends EventEmitter {
console.log(`-> Service ${Util.inspect(query)} found ${Util.inspect(service)}`);
const branches = service.branches.map((branch) => {
return Object.assign({}, branch, {
instances: this._instancesFilter(branch.instances)
});
});
return cb(null, Transform.fromService({
service,
branches: service.branches.map((service) => {
return Object.assign({}, service, {
instances: this._instancesFilter(service.instances)
});
}),
branches,
instances: this._instancesFilter(service.instance_ids)
}));
});
@ -1517,7 +1519,17 @@ class Data extends EventEmitter {
}
return cb(null, services.map((service) => {
return Transform.fromService({ service, instances: this._instancesFilter(service.instance_ids) });
const branches = service.branches.map((branch) => {
return Object.assign({}, branch, {
instances: this._instancesFilter(branch.instances)
});
});
return Transform.fromService({
service,
branches,
instances: this._instancesFilter(service.instance_ids)
});
}));
});
}

View File

@ -63,7 +63,7 @@ exports.toDeploymentGroup = function (clientDeploymentGroup) {
};
exports.fromService = function ({ service, instances, packages }) {
exports.fromService = function ({ service, instances, branches, packages }) {
return {
id: service.id,
hash: service.version_hash,
@ -72,7 +72,7 @@ exports.fromService = function ({ service, instances, packages }) {
slug: service.slug,
instances,
connections: service.service_dependency_ids,
branches: service.branches,
branches: branches,
config: service.config ? service.config : undefined,
status: service.status,
hasPlan: service.has_plan

View File

@ -342,7 +342,8 @@ module.exports = class ContainerPilotWatcher extends Events {
return serviceId;
}, null);
})
.filter(Boolean);
.filter(Boolean)
.filter((serviceId) => service.id !== serviceId);
}
_resolveInstanceHealth ({ name }, instance) {
@ -377,6 +378,10 @@ module.exports = class ContainerPilotWatcher extends Events {
}
_resolveServiceBranches ({ name, slug, instances }) {
if (instances.length <= 1) {
return [];
}
const deviantJobNames = Uniq(Flatten(instances.map(({ jobs }) => {
return Flatten(jobs.filter((jobName) => {
return new RegExp(`${name}-.*`).test(jobName);