From f7075d7db9c836b44d3fb8512211bbaefc3d0f6f Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 14 Nov 2017 13:46:52 +0100 Subject: [PATCH] Fix issue where network settings were not used by `config generate` Change-Type: patch --- build/utils/config.js | 14 +++++++++++--- lib/utils/config.coffee | 10 +++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/build/utils/config.js b/build/utils/config.js index bf0db123..82f5b529 100644 --- a/build/utils/config.js +++ b/build/utils/config.js @@ -18,10 +18,18 @@ limitations under the License. var authenticateWithApplicationKey, authenticateWithDeviceKey; exports.generateBaseConfig = function(application, options) { - var Promise, deviceConfig, resin; + var Promise, _, deviceConfig, resin; Promise = require('bluebird'); + _ = require('lodash'); deviceConfig = require('resin-device-config'); resin = require('resin-sdk-preconfigured'); + options = _.mapValues(options, function(value, key) { + if (key === 'appUpdatePollInterval') { + return value * 60 * 1000; + } else { + return value; + } + }); return Promise.props({ userId: resin.auth.getUserId(), username: resin.auth.whoami(), @@ -48,12 +56,12 @@ exports.generateBaseConfig = function(application, options) { mixpanel: { token: results.mixpanelToken } - }); + }, options); }); }; exports.generateApplicationConfig = function(application, options) { - return exports.generateBaseConfig(application).tap(function(config) { + return exports.generateBaseConfig(application, options).tap(function(config) { return authenticateWithApplicationKey(config, application.id); }); }; diff --git a/lib/utils/config.coffee b/lib/utils/config.coffee index cf802d46..aa2ff238 100644 --- a/lib/utils/config.coffee +++ b/lib/utils/config.coffee @@ -16,9 +16,16 @@ limitations under the License. exports.generateBaseConfig = (application, options) -> Promise = require('bluebird') + _ = require('lodash') deviceConfig = require('resin-device-config') resin = require('resin-sdk-preconfigured') + options = _.mapValues options, (value, key) -> + if key == 'appUpdatePollInterval' + value * 60 * 1000 + else + value + Promise.props userId: resin.auth.getUserId() username: resin.auth.whoami() @@ -42,9 +49,10 @@ exports.generateBaseConfig = (application, options) -> pubnub: results.pubNubKeys mixpanel: token: results.mixpanelToken + , options exports.generateApplicationConfig = (application, options) -> - exports.generateBaseConfig(application) + exports.generateBaseConfig(application, options) .tap (config) -> authenticateWithApplicationKey(config, application.id)