mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-20 22:23:07 +00:00
Make environment variables model callback based
This commit is contained in:
parent
fa83019945
commit
debc017ba3
@ -13,17 +13,15 @@ exports.list = authHooks.failIfNotLoggedIn (program) ->
|
||||
if not applicationId?
|
||||
resin.errors.handle(new Error('You have to specify an application'))
|
||||
|
||||
resin.models.environmentVariables.getAll(applicationId).then (environmentVariables) ->
|
||||
resin.models.environmentVariables.getAll applicationId, (error, environmentVariables) ->
|
||||
resin.errors.handle(error) if error?
|
||||
|
||||
if not program.parent.verbose?
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
||||
|
||||
resin.log.out(resin.ui.widgets.table.horizontal(environmentVariables))
|
||||
.catch(resin.errors.handle)
|
||||
|
||||
exports.remove = authHooks.failIfNotLoggedIn (id, program) ->
|
||||
resin.ui.patterns.remove 'environment variable', program.parent.yes, (callback) ->
|
||||
resin.models.environmentVariables.remove(id).then ->
|
||||
return callback()
|
||||
.catch(callback)
|
||||
resin.models.environmentVariables.remove(id, callback)
|
||||
, resin.errors.handle
|
||||
|
@ -1,8 +1,7 @@
|
||||
Promise = require('bluebird')
|
||||
canvas = require('./_canvas')
|
||||
errors = require('../errors/errors')
|
||||
|
||||
exports.getAll = (applicationId) ->
|
||||
exports.getAll = (applicationId, callback) ->
|
||||
return canvas.get
|
||||
resource: 'environment_variable'
|
||||
options:
|
||||
@ -12,10 +11,18 @@ exports.getAll = (applicationId) ->
|
||||
|
||||
.then (environmentVariables) ->
|
||||
if not environmentVariables?
|
||||
return Promise.reject(new errors.NotFound('environment variables'))
|
||||
return environmentVariables
|
||||
return callback(new errors.NotFound('environment variables'))
|
||||
|
||||
exports.remove = (id) ->
|
||||
return callback(null, environmentVariables)
|
||||
|
||||
.catch (error) ->
|
||||
return callback(error)
|
||||
|
||||
exports.remove = (id, callback) ->
|
||||
return canvas.delete
|
||||
resource: 'environment_variable'
|
||||
id: id
|
||||
.then ->
|
||||
return callback()
|
||||
.catch (error) ->
|
||||
return callback(error)
|
||||
|
Loading…
Reference in New Issue
Block a user