Use the resin-platform-api to access the platform.

This commit is contained in:
Page 2014-03-14 16:06:23 +00:00 committed by Pablo Carranza Vélez
parent c8d8ca9736
commit a5aaee107d
2 changed files with 13 additions and 7 deletions

View File

@ -16,7 +16,8 @@
"bluebird": "~1.1.1",
"JSONStream": "~0.7.1",
"event-stream": "~3.0.20",
"sqlite3": "~2.1.19"
"sqlite3": "~2.1.19",
"resin-platform-api": "git+ssh://git@bitbucket.org:rulemotion/resin-platform-api.git#v0.2.3"
},
"engines": {
"node": "0.10.22"

View File

@ -8,6 +8,8 @@ Docker = require 'dockerode'
Promise = require 'bluebird'
request = Promise.promisify require 'request'
JSONStream = require 'JSONStream'
PlatformAPI = require 'resin-platform-api/request'
resinAPI = new PlatformAPI(url.resolve(process.env.API_ENDPOINT, '/ewa/'))
docker = Promise.promisifyAll(new Docker(socketPath: '/run/docker.sock'))
# Hack dockerode to promisify internal classes' prototypes
@ -84,14 +86,17 @@ exports.update = ->
.then ([[apiKey], [uuid], apps]) ->
apiKey = apiKey.value
uuid = uuid.value
request(
method: 'GET'
url: url.resolve(process.env.API_ENDPOINT, "/ewa/application?$filter=device/uuid eq '#{uuid}'&apikey=#{apiKey}")
json: true
resinAPI.get(
resource: 'application'
options:
filter:
'device/uuid': uuid
customOptions:
apikey: apiKey
)
.spread (request, body) ->
.then (remoteApps) ->
console.log("Remote apps")
remoteApps = ("registry.resin.io/#{path.basename(app.git_repository, '.git')}/#{app.commit}" for app in body.d when app.commit)
remoteApps = ("registry.resin.io/#{path.basename(app.git_repository, '.git')}/#{app.commit}" for app in remoteApps when app.commit)
console.log(remoteApps)
console.log("Local apps")