mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-06-17 07:18:08 +00:00
Attempt to get device type from the image first partition
New images will ship a `device-type.json` file in the first partition, which we can use instead of querying the API for certain configuration and initialisation commands. If the file is not found, or is malformed, we still fallback to the API. Signed-off-by: Juan Cruz Viotti <jviotti@openmailbox.org>
This commit is contained in:
@ -19,6 +19,9 @@ capitano = Promise.promisifyAll(require('capitano'))
|
||||
_ = require('lodash')
|
||||
_.str = require('underscore.string')
|
||||
president = Promise.promisifyAll(require('president'))
|
||||
resin = require('resin-sdk')
|
||||
imagefs = require('resin-image-fs')
|
||||
rindle = require('rindle')
|
||||
os = require('os')
|
||||
chalk = require('chalk')
|
||||
|
||||
@ -52,3 +55,18 @@ exports.sudo = (command, message) ->
|
||||
console.log('Type your computer password to continue')
|
||||
|
||||
return president.executeAsync(command)
|
||||
|
||||
exports.getManifest = (image, deviceType) ->
|
||||
|
||||
# Attempt to read manifest from the first
|
||||
# partition, but fallback to the API if
|
||||
# we encounter any errors along the way.
|
||||
imagefs.read
|
||||
image: image
|
||||
partition:
|
||||
primary: 1
|
||||
path: '/device-type.json'
|
||||
.then(rindle.extractAsync)
|
||||
.then(JSON.parse)
|
||||
.catch ->
|
||||
resin.models.device.getManifestBySlug(deviceType)
|
||||
|
Reference in New Issue
Block a user