DeviceConfig: avoid trying to enable or disable the VPN when in offline mode

Change-Type: patch
Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
This commit is contained in:
Pablo Carranza Velez 2018-03-13 19:54:50 -03:00 committed by Akis Kesoglou
parent f99f59c6ae
commit 1febdc9eb0

View File

@ -148,8 +148,8 @@ module.exports = class DeviceConfig
current = _.clone(currentState.local?.config ? {})
target = _.clone(targetState.local?.config ? {})
steps = []
@config.get('deviceType')
.then (deviceType) =>
@config.getMany([ 'deviceType', 'offlineMode' ])
.then ({ deviceType, offlineMode }) =>
configChanges = {}
humanReadableConfigChanges = {}
match = {
@ -178,11 +178,13 @@ module.exports = class DeviceConfig
action: 'setLogToDisplay'
target: target['RESIN_HOST_LOG_TO_DISPLAY']
})
if !_.isEmpty(target['RESIN_SUPERVISOR_VPN_CONTROL']) && checkTruthy(current['RESIN_SUPERVISOR_VPN_CONTROL']) != checkTruthy(target['RESIN_SUPERVISOR_VPN_CONTROL'])
steps.push({
action: 'setVPNEnabled'
target: target['RESIN_SUPERVISOR_VPN_CONTROL']
})
if !checkTruthy(offlineMode) &&
!_.isEmpty(target['RESIN_SUPERVISOR_VPN_CONTROL']) &&
checkTruthy(current['RESIN_SUPERVISOR_VPN_CONTROL']) != checkTruthy(target['RESIN_SUPERVISOR_VPN_CONTROL'])
steps.push({
action: 'setVPNEnabled'
target: target['RESIN_SUPERVISOR_VPN_CONTROL']
})
if @bootConfigChangeRequired(deviceType, current, target)
steps.push({
action: 'setBootConfig'