Skip to content

Commit

Permalink
Plugin lock
Browse files Browse the repository at this point in the history
  • Loading branch information
apocas committed Mar 1, 2017
1 parent 29fda04 commit d6b2f1d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 39 deletions.
14 changes: 7 additions & 7 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dockerode",
"description": "Docker Remote API module.",
"version": "2.3.1",
"version": "2.3.2",
"author": "Pedro Dias <[email protected]>",
"maintainers": [
"apocas <[email protected]>"
Expand Down
66 changes: 35 additions & 31 deletions test/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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);
Expand All @@ -86,19 +82,26 @@ 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) {
this.timeout(15000);
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();
}

Expand All @@ -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);
});

});
});

0 comments on commit d6b2f1d

Please sign in to comment.