1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 23:30:05 +02:00

feat(portal-data): importable() don't list already imported DeploymentGroups

This commit is contained in:
Sérgio Ramos 2017-06-27 16:14:00 +01:00 committed by Judit Greskovits
parent 12fa092c3b
commit 05bc971a58

View File

@ -1380,23 +1380,32 @@ module.exports = class Data extends EventEmitter {
return cb(null, []); return cb(null, []);
} }
return cb( this.getDeploymentGroups({}, (err, dgs) => {
null, if (err) {
UniqBy( return cb(err);
machines }
.filter(({ state }) => { return NON_IMPORTABLE_STATES.indexOf(state.toUpperCase()) < 0; })
.filter(({ tags = {} }) => { return [DEPLOYMENT_GROUP, SERVICE, HASH].every((name) => { return tags[name]; }); } const names = dgs.map(({ name }) => { return name; });
)
.map(({ tags = {} }) => { return cb(
return ({ null,
id: Uuid(), UniqBy(
name: tags[DEPLOYMENT_GROUP], machines
slug: ParamCase(tags[DEPLOYMENT_GROUP]) .filter(({ tags = {} }) => { return names.indexOf(tags[DEPLOYMENT_GROUP]) < 0; })
}); .filter(({ state }) => { return NON_IMPORTABLE_STATES.indexOf(state.toUpperCase()) < 0; })
}), .filter(({ tags = {} }) => { return [DEPLOYMENT_GROUP, SERVICE, HASH].every((name) => { return tags[name]; }); }
'slug' )
) .map(({ tags = {} }) => {
); return ({
id: Uuid(),
name: tags[DEPLOYMENT_GROUP],
slug: ParamCase(tags[DEPLOYMENT_GROUP])
});
}),
'slug'
)
);
});
} }
importDeploymentGroup ({ deploymentGroupSlug }, cb) { importDeploymentGroup ({ deploymentGroupSlug }, cb) {