Implement env rename command

This commit is contained in:
Juan Cruz Viotti 2014-12-19 14:28:03 -04:00
parent de4c3c986e
commit eb34d957f3
3 changed files with 38 additions and 0 deletions

View File

@ -39,3 +39,7 @@ exports.add = permissions.user (params, options) ->
resin.models.environmentVariables.create options.application, params.key, params.value, (error) ->
resin.errors.handle(error) if error?
exports.rename = permissions.user (params, options) ->
resin.models.environmentVariables.update params.id, params.value, (error) ->
resin.errors.handle(error) if error?

View File

@ -363,6 +363,17 @@ capitano.command
options: [ applicationOption ]
action: actions.env.add
capitano.command
signature: 'env rename <id> <value>'
description: 'rename an environment variable'
help: '''
Use this command to rename an enviroment variable from an application.
Examples:
$ resin env rename 376 emacs
'''
action: actions.env.rename
capitano.command
signature: 'env rm <id>'
description: 'remove an environment variable'

View File

@ -55,6 +55,29 @@ exports.create = (applicationId, name, value, callback) ->
.catch (error) ->
return callback(error)
# Update an environment variable value from an application
#
# @param {String, Number} applicationId application id
# @param {String} value environment variable value
# @param {Function} callback callback(error)
#
# @example Update an environment variable
# resin.models.environmentVariables.update 317, 'vim', (error) ->
# throw error if error?
#
exports.update = (id, value, callback) ->
return pine.patch
resource: 'environment_variable'
id: id
data:
value: value
.then ->
return callback()
.catch (error) ->
return callback(error)
# Remove environment variable
#
# @param {String, Number} id environment variable id