From ac3e31edfb704e5305a1c55db0cebb51486dc75f Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Thu, 18 Jan 2018 15:32:49 -0300 Subject: [PATCH] Support the legacy RESIN_OVERRIDE_LOCK Signed-off-by: Pablo Carranza Velez --- src/device-config.coffee | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/device-config.coffee b/src/device-config.coffee index 7af0b862..0d5a7db4 100644 --- a/src/device-config.coffee +++ b/src/device-config.coffee @@ -50,7 +50,7 @@ module.exports = class DeviceConfig deltaRetryInterval: { envVarName: 'RESIN_SUPERVISOR_DELTA_RETRY_INTERVAL', varType: 'int' } lockOverride: { envVarName: 'RESIN_SUPERVISOR_OVERRIDE_LOCK', varType: 'bool', defaultValue: 'false' } } - @validKeys = [ 'RESIN_HOST_LOG_TO_DISPLAY', 'RESIN_SUPERVISOR_VPN_CONTROL' ].concat(_.map(@configKeys, 'envVarName')) + @validKeys = [ 'RESIN_HOST_LOG_TO_DISPLAY', 'RESIN_SUPERVISOR_VPN_CONTROL', 'RESIN_OVERRIDE_LOCK' ].concat(_.map(@configKeys, 'envVarName')) @actionExecutors = { changeConfig: (step) => @logger.logConfigChange(step.humanReadableTarget) @@ -141,8 +141,8 @@ module.exports = class DeviceConfig else return false getRequiredSteps: (currentState, targetState, stepsInProgress) => - current = currentState.local?.config ? {} - target = targetState.local?.config ? {} + current = _.clone(currentState.local?.config ? {}) + target = _.clone(targetState.local?.config ? {}) steps = [] @config.get('deviceType') .then (deviceType) => @@ -154,6 +154,9 @@ module.exports = class DeviceConfig 'int': (a, b) -> checkInt(a) == checkInt(b) } + # If the legacy lock override is used, place it as the new variable + if checkTruthy(target['RESIN_OVERRIDE_LOCK']) + target['RESIN_SUPERVISOR_OVERRIDE_LOCK'] = target['RESIN_OVERRIDE_LOCK'] for own key, { envVarName, varType } of @configKeys if !match[varType](current[envVarName], target[envVarName]) configChanges[key] = target[envVarName]