diff --git a/lib/plugin.js b/lib/plugin.js index 4a44bcd..f50e8b2 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -47,7 +47,7 @@ Plugin.prototype.remove = function(opts, callback) { var args = util.processArgs(opts, callback); var optsf = { - path: '/plugins/' + this.name, + path: '/plugins/' + this.name + '?', method: 'DELETE', statusCodes: { 200: true, @@ -92,14 +92,14 @@ Plugin.prototype.privileges = function(callback) { * @param {Object} opts Create options * @param {Function} callback Callback */ -Plugin.prototype.install = function(opts, callback) { +Plugin.prototype.pull = function(opts, callback) { var args = util.processArgs(opts, callback); - if(args.opts.query && !args.opts.query.name) { - args.opts.query.name = this.name; + if(args.opts._query && !args.opts._query.name) { + args.opts._query.name = this.name; } - if(args.opts.query && !args.opts.query.remote) { - args.opts.query.remote = this.remote; + if(args.opts._query && !args.opts._query.remote) { + args.opts._query.remote = this.remote; } var self = this; @@ -130,7 +130,7 @@ Plugin.prototype.enable = function(opts, callback) { var args = util.processArgs(opts, callback); var optsf = { - path: '/plugins/' + this.name + '/enable', + path: '/plugins/' + this.name + '/enable?', method: 'POST', statusCodes: { 200: true, diff --git a/package.json b/package.json index 826268e..c38dc78 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dockerode", "description": "Docker Remote API module.", - "version": "2.3.1", + "version": "2.3.2", "author": "Pedro Dias ", "maintainers": [ "apocas " diff --git a/test/plugin.js b/test/plugin.js index 6d1e492..df571a1 100644 --- a/test/plugin.js +++ b/test/plugin.js @@ -21,15 +21,15 @@ describe("#plugin", function() { }); describe("#install", function() { + var installed = false; it("should get plugin privileges", function(done) { this.timeout(15000); - var plugin = docker.getPlugin('sshfs', 'vieux/sshfs'); + var plugin = docker.getPlugin('vieux/sshfs'); function handler(err, data) { expect(err).to.be.null; expect(data).to.be.a('array'); - console.log(data); done(); } @@ -42,35 +42,31 @@ describe("#plugin", function() { var plugin = docker.getPlugin('sshfs'); //geezzz url, querystring and body... - plugin.install({ + plugin.pull({ '_query': { 'remote': 'vieux/sshfs' }, '_body': [{ - 'Name': 'network', - 'Description': '', - 'Value': [ - 'host' - ] - }, { - 'Name': 'capabilities', - 'Description': '', - 'Value': [ - 'CAP_SYS_ADMIN' - ] - }, { - 'Name': 'mount', - 'Description': '', - 'Value': [ - '/var/lib/docker/plugins/' - ] - }, { - 'Name': 'device', - 'Description': '', - 'Value': [ - '/dev/fuse' - ] - }] + 'Name': 'network', + 'Description': 'permissions to access a network', + 'Value': ['host'] + }, + { + 'Name': 'mount', + 'Description': 'host path to mount', + 'Value': ['/var/lib/docker/plugins/'] + }, + { + 'Name': 'device', + 'Description': 'host device to access', + 'Value': ['/dev/fuse'] + }, + { + 'Name': 'capabilities', + 'Description': 'list of additional capabilities required', + 'Value': ['CAP_SYS_ADMIN'] + } + ] }, function(err, stream) { if (err) return done(err); stream.pipe(process.stdout); @@ -86,10 +82,13 @@ describe("#plugin", function() { function handler(err, data) { expect(err).to.be.null; expect(data).to.be.ok; + installed = true; done(); } - plugin.enable(handler); + plugin.enable({ + 'Timeout': 5 + }, handler); }); it("should disable a plugin", function(done) { @@ -97,8 +96,12 @@ describe("#plugin", function() { var plugin = docker.getPlugin('sshfs'); function handler(err, data) { - expect(err).to.be.null; - expect(data).to.be.ok; + if (installed === true) { + expect(err).to.be.null; + expect(data).to.be.ok; + } else { + expect(err).to.be.ok; + } done(); } @@ -111,11 +114,12 @@ describe("#plugin", function() { function handler(err, data) { expect(err).to.be.null; - expect(data).to.be.ok; + expect(data).to.be.empty; done(); } plugin.remove(handler); }); + }); });