Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fix] When only one cloud is passed to Client.prototype.cloud then …
…respond with an unwrapped result.
  • Loading branch information
indexzero committed Feb 6, 2013
1 parent 8c08d5c commit bd283e5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion node.js/lib/client/client.js
Expand Up @@ -115,7 +115,10 @@ Client.prototype.cloud = function (options, api, callback) {
api.call(self, opts, done);
}, function ready(err, results) {
if (err) delete self.clouds[options.appName];
callback(err, results);

return results.length === 1
? callback(err, results[0])
: callback(err, results)

//
// We probably want to figure out which calls went okay, and which one
Expand Down

3 comments on commit bd283e5

@indexzero
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3rd-Eden I believe that this is one of the sources for your problem with the api returning:

  [ [ { datacenter: 'us-east-1', provider: 'joyent', drones: 2 } ] ]

You're mapping over the clouds for the specified options.appName here and then directly returning those results in the line removed from this commit.

So since POST /apps/:user/:app/cloud returns an Array, you were responding with an Array of Arrays.

@3rd-Eden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@indexzero I thought that it was already fixed as it was caused by something else. But this fix seems reasonable as the mapping does indeed wrap everything in an Array. My only concern here is that the response will change once we call multiple datacenters and it might not be obvious of where that's coming from. But that's probably something for later.

@3rd-Eden
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I do find a bit odd and disturbing that everything was still working and the tests passed if it was always returning the result wrapped in a Array

Please sign in to comment.