From 0e4c6c459c3800f2b656041d524eb7ff12ae44fc Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 17 Oct 2017 17:28:40 +0200 Subject: [PATCH] Fix issue where `os download` would always download prod images This also adds support for submodules using resin-sdk shared options rather than resin-sdk-preconfigured. Change-Type: patch Connects-To: #688 --- build/actions/os.js | 3 +++ build/app.js | 7 +++++++ lib/actions/os.coffee | 2 ++ lib/app.coffee | 11 +++++++++++ package.json | 5 +++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/build/actions/os.js b/build/actions/os.js index b16423f8..35d207d8 100644 --- a/build/actions/os.js +++ b/build/actions/os.js @@ -33,6 +33,9 @@ formatVersion = function(v, isRecommended) { resolveVersion = function(deviceType, version) { var form, resin; if (version !== 'menu') { + if (version[0] === 'v') { + version = version.slice(1); + } return Promise.resolve(version); } form = require('resin-cli-form'); diff --git a/build/app.js b/build/app.js index 151dc430..f6bff0be 100644 --- a/build/app.js +++ b/build/app.js @@ -64,6 +64,13 @@ capitano = require('capitano'); capitanoExecuteAsync = Promise.promisify(capitano.execute); +require('resin-sdk').setSharedOptions({ + apiUrl: settings.get('apiUrl'), + imageMakerUrl: settings.get('imageMakerUrl'), + dataDirectory: settings.get('dataDirectory'), + retries: 2 +}); + resin = require('resin-sdk-preconfigured'); actions = require('./actions'); diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index d3ec1148..9c57332e 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -25,6 +25,8 @@ formatVersion = (v, isRecommended) -> resolveVersion = (deviceType, version) -> if version isnt 'menu' + if version[0] == 'v' + version = version.slice(1) return Promise.resolve(version) form = require('resin-cli-form') diff --git a/lib/app.coffee b/lib/app.coffee index 643c3c73..d43b0941 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -60,7 +60,18 @@ _ = require('lodash') Promise = require('bluebird') capitano = require('capitano') capitanoExecuteAsync = Promise.promisify(capitano.execute) + +# We don't yet use resin-sdk directly everywhere, but we set up shared +# options correctly so we can do safely in submodules +require('resin-sdk').setSharedOptions( + apiUrl: settings.get('apiUrl') + imageMakerUrl: settings.get('imageMakerUrl') + dataDirectory: settings.get('dataDirectory') + retries: 2 +) +# Keep using sdk-preconfigured for now, but only temporarily resin = require('resin-sdk-preconfigured') + actions = require('./actions') errors = require('./errors') events = require('./events') diff --git a/package.json b/package.json index 09854209..ac523bbb 100644 --- a/package.json +++ b/package.json @@ -85,8 +85,9 @@ "resin-docker-build": "^0.4.0", "resin-doodles": "0.0.1", "resin-image-fs": "^2.3.0", - "resin-image-manager": "^4.1.1", + "resin-image-manager": "^5.0.0", "resin-preload": "^4.0.2", + "resin-sdk": "^7.0.0", "resin-sdk-preconfigured": "^6.9.0", "resin-settings-client": "^3.6.1", "resin-stream-logger": "^0.0.4", @@ -104,4 +105,4 @@ "optionalDependencies": { "removedrive": "^1.0.0" } -} \ No newline at end of file +}