1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

fix(portal-data): use version() when provisioning

This commit is contained in:
Sérgio Ramos 2017-06-27 17:44:14 +01:00 committed by Judit Greskovits
parent 3f1625aa5a
commit 3aa7ec54bb

View File

@ -269,7 +269,9 @@ module.exports = class Data extends EventEmitter {
args.id = deploymentGroup.version_id; args.id = deploymentGroup.version_id;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.getVersion(args, resolveCb(resolve, reject)); return deploymentGroup.version_id
? this.getVersion(args, resolveCb(resolve, reject))
: resolve(null);
}); });
}; };
@ -701,31 +703,19 @@ module.exports = class Data extends EventEmitter {
console.log(`-> new Manifest created with id ${manifestId}`); console.log(`-> new Manifest created with id ${manifestId}`);
if (!deploymentGroup.version) { deploymentGroup.version().then((currentVersion) => {
console.log(`-> detected first provision for DeploymentGroup ${deploymentGroup.id}`); if (!currentVersion) {
return createVersion({ console.log(`-> detected first provision for DeploymentGroup ${deploymentGroup.id}`);
deploymentGroup, } else {
manifest: { id: manifestId }, console.log(`-> creating new Version based on old version ${currentVersion.id}`);
currentVersion: {}
});
}
// get current version for because we need current scale
this.getVersion({
id: deploymentGroup.version
}, (err, currentVersion) => {
if (err) {
return cb(err);
} }
console.log(`-> creating new Version based on old version ${currentVersion.id}`);
return createVersion({ return createVersion({
deploymentGroup, deploymentGroup,
manifest: { id: manifestId }, manifest: { id: manifestId },
currentVersion currentVersion: currentVersion || {}
}); });
}); }).catch((err) => cb(err));
}); });
}); });
} }