diff --git a/src/apps.js b/src/apps.js index 314a46b90..b776d8d87 100644 --- a/src/apps.js +++ b/src/apps.js @@ -535,17 +535,19 @@ function configure(appId, data, auditSource, callback) { }); } -function update(appId, force, manifest, portBindings, icon, auditSource, callback) { +function update(appId, data, auditSource, callback) { assert.strictEqual(typeof appId, 'string'); - assert.strictEqual(typeof force, 'boolean'); - assert(manifest && typeof manifest === 'object'); - assert(typeof portBindings === 'object'); // can be null - assert(!icon || typeof icon === 'string'); + assert(data && typeof data === 'object'); assert.strictEqual(typeof auditSource, 'object'); assert.strictEqual(typeof callback, 'function'); debug('Will update app with id:%s', appId); + var manifest = data.manifest, + force = data.force || false, + portBindings = data.portBindings || null, + icon = data.icon || null; + var error = manifestFormat.parse(manifest); if (error) return callback(new AppsError(AppsError.BAD_FIELD, 'Manifest error:' + error.message)); @@ -866,8 +868,14 @@ function updateApps(updateInfo, auditSource, callback) { // updateInfo is { appI return iteratorDone(); } - update(appId, false /* force */, updateInfo[appId].manifest, app.portBindings, - null /* icon */, auditSource, function (error) { + var data = { + force: false, + manifest: updateInfo[appId].manifest, + portBindings: app.portBindings, + icon: null + }; + + update(appId, data, auditSource, function (error) { if (error) debug('Error initiating autoupdate of %s. %s', appId, error.message); iteratorDone(null); diff --git a/src/routes/apps.js b/src/routes/apps.js index 5fc167fce..10ccbda56 100644 --- a/src/routes/apps.js +++ b/src/routes/apps.js @@ -254,7 +254,7 @@ function updateApp(req, res, next) { debug('Update app id:%s to manifest:%j with portBindings:%j', req.params.id, data.manifest, data.portBindings); - apps.update(req.params.id, data.force || false, data.manifest, data.portBindings || null, data.icon, auditSource(req), function (error) { + apps.update(req.params.id, req.body, auditSource(req), function (error) { if (error && error.reason === AppsError.NOT_FOUND) return next(new HttpError(404, 'No such app')); if (error && error.reason === AppsError.BAD_FIELD) return next(new HttpError(400, error.message)); if (error && error.reason === AppsError.BAD_STATE) return next(new HttpError(409, error.message));