migrate app dataDir to volumes

This commit is contained in:
Girish Ramakrishnan
2022-06-01 22:44:52 -07:00
parent 8fc8128957
commit dddc5a1994
12 changed files with 117 additions and 62 deletions

View File

@@ -35,7 +35,7 @@ exports = module.exports = {
setMailbox,
setInbox,
setLocation,
setDataDir,
setStorage,
setMounts,
stop,
@@ -432,13 +432,14 @@ async function setLocation(req, res, next) {
next(new HttpSuccess(202, { taskId: result.taskId }));
}
async function setDataDir(req, res, next) {
async function setStorage(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
assert.strictEqual(typeof req.app, 'object');
if (req.body.dataDir !== null && typeof req.body.dataDir !== 'string') return next(new HttpError(400, 'dataDir must be a string'));
if (req.body.storageVolumeId !== null && typeof req.body.dataVolumeId !== 'string') return next(new HttpError(400, 'storageVolumeId must be a string'));
if (req.body.storageVolumePrefix !== null && typeof req.body.storageVolumePrefix !== 'string') return next(new HttpError(400, 'storageVolumePrefix must be a string'));
const [error, result] = await safe(apps.setDataDir(req.app, req.body.dataDir, AuditSource.fromRequest(req)));
const [error, result] = await safe(apps.setStorage(req.app, req.body.storageVolumeId, req.body.storageVolumePrefix, AuditSource.fromRequest(req)));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(202, { taskId: result.taskId }));