diff --git a/lib/actions/environment-variables.coffee b/lib/actions/environment-variables.coffee index be686885..c5e17ff0 100644 --- a/lib/actions/environment-variables.coffee +++ b/lib/actions/environment-variables.coffee @@ -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 diff --git a/lib/resin/models/environment-variables.coffee b/lib/resin/models/environment-variables.coffee index 06282a79..76a5e89c 100644 --- a/lib/resin/models/environment-variables.coffee +++ b/lib/resin/models/environment-variables.coffee @@ -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)