Permalink
Browse files

refactor jitsu keys to work with nodejitsu-api.

  • Loading branch information...
1 parent fba2770 commit 33ccc7332ee8db12cf6558753fdb7eb45541bd6d @chjj chjj committed Apr 9, 2012
Showing with 15 additions and 17 deletions.
  1. +15 −17 lib/jitsu/commands/keys.js
View
32 lib/jitsu/commands/keys.js
@@ -25,7 +25,8 @@ keys.create = function (username, data, callback) {
if (data.path) {
fs.readFile(data.path, 'utf8', function(err, val) {
if (err) return callback(err);
- data.value = val.split(/\s+/)[1];
+ val = val.split(/\s+/);
+ data.value = val[1] || val[0];
delete data.path;
return next();
});
@@ -34,7 +35,7 @@ keys.create = function (username, data, callback) {
}
function next() {
- jitsu.users.createKey(user, data.name, function (err, response) {
+ jitsu.keys.create(user, data, function (err, response) {
if (err) return callback(err);
jitsu.log.help('Key successfully created.');
});
@@ -45,10 +46,9 @@ keys.create = function (username, data, callback) {
// Usage for `jitsu keys create`.
//
keys.create.usage = [
- 'Confirms the Nodejitsu user account for the specified username.',
- 'You will be prompted to supply a valid invite code for the account.',
+ 'Adds a key to jitsu, if no path is specified, generate random API key.',
'',
- 'jitsu keys confirm <username> <invitecode>'
+ 'jitsu keys create <name> <path>'
];
//
@@ -63,7 +63,7 @@ keys.list = function (username, callback) {
password: jitsu.config.get('password')
};
- jitsu.users.listKeys(user, function (err, keys) {
+ jitsu.keys.list(user, function (err, keys) {
if (err) return callback(err);
var rows = [['name', 'state', 'subdomain', 'start', 'latest']],
@@ -87,10 +87,9 @@ keys.list = function (username, callback) {
// Usage for `jitsu keys list`.
//
keys.list.usage = [
- 'Confirms the Nodejitsu user account for the specified username.',
- 'You will be prompted to supply a valid invite code for the account.',
+ 'List all API and SSH keys.',
'',
- 'jitsu keys confirm <username> <invitecode>'
+ 'jitsu keys list'
];
//
@@ -106,7 +105,7 @@ keys.view = function (username, keyName, callback) {
password: jitsu.config.get('password')
};
- jitsu.users.getKey(user, keyName, function (err, key) {
+ jitsu.keys.view(user, keyName, function (err, key) {
if (err) return callback(err);
jitsu.inspect.putObject(key);
});
@@ -116,10 +115,9 @@ keys.view = function (username, keyName, callback) {
// Usage for `jitsu keys view`.
//
keys.view.usage = [
- 'Confirms the Nodejitsu user account for the specified username.',
- 'You will be prompted to supply a valid invite code for the account.',
+ 'View a specific API or SSH key by name.',
'',
- 'jitsu keys confirm <username> <invitecode>'
+ 'jitsu keys view <name>'
];
//
@@ -135,7 +133,8 @@ keys.delete = function (username, keyName, callback) {
password: jitsu.config.get('password')
};
- jitsu.users.deleteKey(user, keyName, function (err) {
+ // fix this ins nodejitsu-api
+ jitsu.keys.destroy(user, keyName, function (err) {
if (err) return callback(err);
jitsu.log.help('Key deleted successfully.');
});
@@ -145,9 +144,8 @@ keys.delete = function (username, keyName, callback) {
// Usage for `jitsu keys delete`.
//
keys.delete.usage = [
- 'Confirms the Nodejitsu user account for the specified username.',
- 'You will be prompted to supply a valid invite code for the account.',
+ 'Delete the specified API or SSH key.',
'',
- 'jitsu keys confirm <username> <invitecode>'
+ 'jitsu keys delete <name>'
];

0 comments on commit 33ccc73

Please sign in to comment.