Skip to content

Commit

Permalink
Merge pull request #218 from rackspace/do-scrub
Browse files Browse the repository at this point in the history
Make default DestroyServer for DigitalOcean scrub private data
  • Loading branch information
kenperkins committed Dec 31, 2013
2 parents d432984 + d10d1e9 commit 2b99678
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
18 changes: 16 additions & 2 deletions lib/pkgcloud/digitalocean/compute/client/servers.js
Expand Up @@ -141,16 +141,30 @@ exports.createServer = function createServer(options, callback) {
//
// ### function destroyServer(server, callback)
// #### @server {Server|String} Server id or a server
// #### [@options] {object} Pass optioos for deletion
// #### [options.scrubData] Optionally disable scrubbing data (boolean),
// default (true) is to scrub data from Digital Ocean servers
//
// #### @callback {Function} f(err, serverId).
//
// Destroy a server in DigitalOcean.
//
exports.destroyServer = function destroyServer(server, callback) {
exports.destroyServer = function destroyServer(server, options, callback) {
var serverId = server instanceof base.Server ? server.id : server,
self = this;

if (typeof options === 'function') {
callback = options;
options = {};
}

this.request({
path: '/droplets/' + serverId + '/destroy'
path: '/droplets/' + serverId + '/destroy',
qs: {
scrub_data: (typeof options.scrubData === 'boolean')
? (options.scrubData ? '1' : '0')
: '1'
}
}, function (err, body, res) {
return err ? callback(err) : callback(null, { ok: serverId }, res);
});
Expand Down
1 change: 1 addition & 0 deletions test/common/compute/base-test.js
Expand Up @@ -512,6 +512,7 @@ function setupDestroyMock(client, provider, servers) {

servers.server
.get('/droplets/354526/destroy?' + qs.stringify({
scrub_data: '1',
client_id: account.clientId,
api_key: account.apiKey
}))
Expand Down
4 changes: 2 additions & 2 deletions test/common/compute/signature-test.js
Expand Up @@ -41,9 +41,9 @@ providers.forEach(function (provider) {
should.ok(client.rebootServer.length >= 2);
});

it('client.destroyServer should take 2 arguments', function () {
it('client.destroyServer should take at least 2 arguments', function () {
client.destroyServer.should.be.a('function');
client.destroyServer.should.have.length(2);
should.ok(client.destroyServer.length >= 2);
});

it('client.getFlavor should take 2 arguments', function () {
Expand Down

0 comments on commit 2b99678

Please sign in to comment.