Cleaning up multi-provider compute methods in pkgcloud

I’ve been spending a fair amount of time looking at the OpenStack and Rackspace compute API implementation (in preparation for a future major update to pkgcloud) and I realized that it’s very easy to make a change to a signature and not realize the cross-provider impact it may have.

For example, consider this multi-provider example:

var pkgcloud = require('pkgcloud'),
    providers = ['amazon', 'joyent', 'rackspace', 'azure', 'openstack'],
    async = require('async'),
    helper = require('helper');
// Loop through our providers and create a client async.forEachSeries(providers, function(provider, next) { var client = pkgcloud.compute.createClient(helper.getProviderConfig(provider));
// Create a new server, and then add a key client.createServer(helper.defaultServerOptions(provider), function(err, server) { client.addKey({
name: 'my-key',
key: 'some-key-value'
}, function(err) {
}); }); }, function(err) { process.exit(0); });

The point is that a subtle change in how one of the providers parses options for either createServer or addKey could result in a failure.

Obviously, we should have test cases for these (we do for a fair number already) but additionally, I think we can do some organizational changes to better communicate to future contributors the implication of being a cross-provider method.

I’ve started a list of the currently implemented APIs for further discussion. View it on GitHub.

0 notes

blog comments powered by Disqus