From 72d04014033539cf23963412a4f92e5ae4df9f88 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 11 Oct 2016 12:06:39 -0300 Subject: [PATCH] Do not use parsed JSON to compare dep. device state --- CHANGELOG.md | 2 ++ src/proxyvisor.coffee | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8be9ae06..c52db932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +Do not use parsed JSON to compare dep. device state [Pablo] + # v2.6.0 * Fix docker utils getImageEnv by correctly parsing the returned array [Pablo] diff --git a/src/proxyvisor.coffee b/src/proxyvisor.coffee index 7475bcb4..a3ab6632 100644 --- a/src/proxyvisor.coffee +++ b/src/proxyvisor.coffee @@ -312,6 +312,13 @@ getHookEndpoint = (appId) -> conf.RESIN_DEPENDENT_DEVICES_HOOK_ADDRESS ? "#{appConfig.proxyvisorHookReceiver}/v1/devices/" +formatTargetAsState = (device) -> + return { + commit: device.targetCommit + environment: device.targetEnvironment + config: device.targetConfig + } + do -> acknowledgedState = {} sendUpdate = (device, endpoint) -> @@ -327,7 +334,7 @@ do -> } .spread (response, body) -> if response.statusCode == 200 - acknowledgedState[device.uuid] = _.omit(stateToSend, 'appId') + acknowledgedState[device.uuid] = formatTargetAsState(device) else acknowledgedState[device.uuid] = null throw new Error("Hook returned #{response.statusCode}: #{body}") if response.statusCode != 202 @@ -350,11 +357,7 @@ do -> knex('dependentDevice').select() .map (device) -> currentState = _.pick(device, 'commit', 'environment', 'config') - targetState = { - commit: device.targetCommit - environment: device.targetEnvironment - config: device.targetConfig - } + targetState = formatTargetAsState(device) endpoints[device.appId] ?= getHookEndpoint(device.appId) endpoints[device.appId] .then (endpoint) ->