Move legacy renaming to formatting function

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-02-04 10:58:39 +00:00
parent f12f474516
commit d75c58f09d
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -216,9 +216,15 @@ export class DeviceConfig {
const db = trx != null ? trx : this.db.models.bind(this.db);
const formatted = await this.formatConfigKeys(target);
// check for legacy keys
if (formatted['OVERRIDE_LOCK'] != null) {
formatted['SUPERVISOR_OVERRIDE_LOCK'] = formatted['OVERRIDE_LOCK'];
}
const confToUpdate = {
targetValues: JSON.stringify(formatted),
};
await db('deviceConfig').update(confToUpdate);
}
@ -356,11 +362,6 @@ export class DeviceConfig {
const humanReadableConfigChanges: Dictionary<string> = {};
let reboot = false;
// If the legacy lock override is used, place it as the new variable
if (checkTruthy(target['OVERRIDE_LOCK'])) {
target['SUPERVISOR_OVERRIDE_LOCK'] = target['OVERRIDE_LOCK'];
}
_.each(
DeviceConfig.configKeys,
({ envVarName, varType, rebootRequired }, key) => {