Show volume edit options for network mounts
This commit is contained in:
+16
-11
@@ -135,28 +135,33 @@ function removePrivateFields(volume) {
|
||||
return newVolume;
|
||||
}
|
||||
|
||||
// only network mounts can be updated here through mountOptions to update logon information
|
||||
async function update(id, mountOptions, auditSource) {
|
||||
assert.strictEqual(typeof id, 'string');
|
||||
assert.strictEqual(typeof mountOptions, 'object');
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
const volume = await get(id);
|
||||
const mountType = volume.mountType;
|
||||
const name = volume.name;
|
||||
|
||||
const error = mounts.validateMountOptions(volume.mountType, mountOptions);
|
||||
if (mountType !== 'cifs' && mountType !== 'sshfs' && mountType !== 'nfs') return;
|
||||
|
||||
const error = mounts.validateMountOptions(mountType, mountOptions);
|
||||
if (error) throw error;
|
||||
|
||||
let hostPath;
|
||||
if (volume.mountType === 'mountpoint' || volume.mountType === 'filesystem') {
|
||||
const error = validateHostPath(mountOptions.hostPath, volume.mountType);
|
||||
if (error) throw error;
|
||||
hostPath = mountOptions.hostPath;
|
||||
} else {
|
||||
hostPath = path.join(paths.VOLUMES_MOUNT_DIR, id);
|
||||
const mount = { name: volume.name, hostPath, mountType: volume.mountType, mountOptions };
|
||||
await mounts.tryAddMount(mount, { timeout: 10 }); // 10 seconds
|
||||
// put old secret back in place if no new secret is provided
|
||||
if (mountType === 'sshfs') {
|
||||
if (mountOptions.privateKey === constants.SECRET_PLACEHOLDER) mountOptions.privateKey = volume.mountOptions.privateKey;
|
||||
} else if (mountType === 'cifs') {
|
||||
if (mountOptions.password === constants.SECRET_PLACEHOLDER) mountOptions.password = volume.mountOptions.password;
|
||||
}
|
||||
|
||||
await safe(database.query('UPDATE volumes SET hostPath=?,mountOptionsJson=? WHERE id=?)', [ hostPath, JSON.stringify(mountOptions), id ]));
|
||||
const hostPath = path.join(paths.VOLUMES_MOUNT_DIR, id);
|
||||
const mount = { name, hostPath, mountType: mountType, mountOptions };
|
||||
await mounts.tryAddMount(mount, { timeout: 10 }); // 10 seconds
|
||||
|
||||
await database.query('UPDATE volumes SET hostPath=?,mountOptionsJson=? WHERE id=?', [ hostPath, JSON.stringify(mountOptions), id ]);
|
||||
|
||||
await eventlog.add(eventlog.ACTION_VOLUME_UPDATE, auditSource, { id, name, hostPath });
|
||||
// in theory, we only need to do this mountpoint volumes. but for some reason a restart is required to detect new "mounts"
|
||||
|
||||
Reference in New Issue
Block a user