check version of app

This commit is contained in:
Girish Ramakrishnan 2016-06-07 16:09:46 -07:00
parent da5045537a
commit 2017ec1841
1 changed files with 10 additions and 5 deletions

View File

@ -116,7 +116,7 @@ Cloudron.prototype.activate = function (user) {
assert.strictEqual(res.body.version, this._box.version);
};
Cloudron.prototype.waitForApp = function (appId) {
Cloudron.prototype.waitForApp = function (appId, version) {
// wait for app to come up
process.stdout.write('Waiting for app to come up.');
@ -134,7 +134,8 @@ Cloudron.prototype.waitForApp = function (appId) {
}
assert.strictEqual(res.body.installationState, 'installed');
assert.strictEqual(res.body.runState, 'running');
assert.strictEqual(res.body.health, 'healthy');
assert.strictEqual(res.body.runState, 'running');
if (version) assert.strictEqual(res.body.manifest.version, version);
return res.body;
};
@ -166,6 +167,8 @@ Cloudron.prototype.setCredentials = function (password, accessToken) {
Cloudron.prototype.installApp = function (location, manifestOrAppstoreId, portBindings) {
portBindings = portBindings || null; // null binds nothing
var version = typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId.version : manifestOrAppstoreId.split('@')[1];
var data = {
manifest: typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId : null,
appStoreId: typeof manifestOrAppstoreId === 'string' ? manifestOrAppstoreId : null,
@ -183,7 +186,7 @@ Cloudron.prototype.installApp = function (location, manifestOrAppstoreId, portBi
debug('App installed at %s'.green, location);
var appId = res.body.id;
var app = this.waitForApp(appId);
var app = this.waitForApp(appId, version);
debug('App is running'.green);
res = request.get('https://' + app.fqdn).end();
@ -233,6 +236,8 @@ Cloudron.prototype.uninstallApp = function (appId) {
Cloudron.prototype.updateApp = function (appId, manifestOrAppstoreId) {
process.stdout.write('Trying to update');
var version = typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId.version : manifestOrAppstoreId.split('@')[1];
var data = {
password: this._credentials.password,
manifest: typeof manifestOrAppstoreId === 'object' ? manifestOrAppstoreId : null,
@ -247,12 +252,12 @@ Cloudron.prototype.updateApp = function (appId, manifestOrAppstoreId) {
console.log('Update started'.green);
var app = this.waitForApp(appId);
var app = this.waitForApp(appId, version);
debug('App is running'.green);
res = request.get('https://' + app.fqdn).end();
common.verifyResponse2xx(res, 'App is unreachable');
console.log('App updated'.green);
console.log('App updated to '.green);
};
Cloudron.prototype.update = function (toVersion) {