add volume support

part of #668, #569
This commit is contained in:
Girish Ramakrishnan
2020-04-22 19:18:04 -07:00
parent b46d3e74d6
commit b8bb69f730
20 changed files with 864 additions and 38 deletions
+19
View File
@@ -21,6 +21,7 @@ exports = module.exports = {
setIcon: setIcon,
setMemoryLimit: setMemoryLimit,
setCpuShares: setCpuShares,
setVolumes: setVolumes,
setAutomaticBackup: setAutomaticBackup,
setAutomaticUpdate: setAutomaticUpdate,
setReverseProxyConfig: setReverseProxyConfig,
@@ -238,6 +239,24 @@ function setCpuShares(req, res, next) {
});
}
function setVolumes(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.resource, 'object');
if (!Array.isArray(req.body.volumes)) return next(new HttpError(400, 'volumes should be an array'));
for (let v of req.body.volumes) {
if (!v || typeof v !== 'object') return next(new HttpError(400, 'volume must be a {id, readOnly}'));
if (typeof v.id !== 'string') return next(new HttpError(400, 'id must be a string'));
if (typeof v.readOnly !== 'boolean') return next(new HttpError(400, 'readOnly must be a boolean'));
}
apps.setVolumes(req.resource, req.body.volumes, auditSource.fromRequest(req), function (error, result) {
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId: result.taskId }));
});
}
function setAutomaticBackup(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.resource, 'object');