Skip to content

Commit d6b2f1d

Browse files
committed
Plugin lock
1 parent 29fda04 commit d6b2f1d

File tree

3 files changed

+43
-39
lines changed

3 files changed

+43
-39
lines changed

lib/plugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Plugin.prototype.remove = function(opts, callback) {
4747
var args = util.processArgs(opts, callback);
4848

4949
var optsf = {
50-
path: '/plugins/' + this.name,
50+
path: '/plugins/' + this.name + '?',
5151
method: 'DELETE',
5252
statusCodes: {
5353
200: true,
@@ -92,14 +92,14 @@ Plugin.prototype.privileges = function(callback) {
9292
* @param {Object} opts Create options
9393
* @param {Function} callback Callback
9494
*/
95-
Plugin.prototype.install = function(opts, callback) {
95+
Plugin.prototype.pull = function(opts, callback) {
9696
var args = util.processArgs(opts, callback);
9797

98-
if(args.opts.query && !args.opts.query.name) {
99-
args.opts.query.name = this.name;
98+
if(args.opts._query && !args.opts._query.name) {
99+
args.opts._query.name = this.name;
100100
}
101-
if(args.opts.query && !args.opts.query.remote) {
102-
args.opts.query.remote = this.remote;
101+
if(args.opts._query && !args.opts._query.remote) {
102+
args.opts._query.remote = this.remote;
103103
}
104104

105105
var self = this;
@@ -130,7 +130,7 @@ Plugin.prototype.enable = function(opts, callback) {
130130
var args = util.processArgs(opts, callback);
131131

132132
var optsf = {
133-
path: '/plugins/' + this.name + '/enable',
133+
path: '/plugins/' + this.name + '/enable?',
134134
method: 'POST',
135135
statusCodes: {
136136
200: true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dockerode",
33
"description": "Docker Remote API module.",
4-
"version": "2.3.1",
4+
"version": "2.3.2",
55
"author": "Pedro Dias <petermdias@gmail.com>",
66
"maintainers": [
77
"apocas <petermdias@gmail.com>"

test/plugin.js

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ describe("#plugin", function() {
2121
});
2222

2323
describe("#install", function() {
24+
var installed = false;
2425

2526
it("should get plugin privileges", function(done) {
2627
this.timeout(15000);
27-
var plugin = docker.getPlugin('sshfs', 'vieux/sshfs');
28+
var plugin = docker.getPlugin('vieux/sshfs');
2829

2930
function handler(err, data) {
3031
expect(err).to.be.null;
3132
expect(data).to.be.a('array');
32-
console.log(data);
3333
done();
3434
}
3535

@@ -42,35 +42,31 @@ describe("#plugin", function() {
4242
var plugin = docker.getPlugin('sshfs');
4343

4444
//geezzz url, querystring and body...
45-
plugin.install({
45+
plugin.pull({
4646
'_query': {
4747
'remote': 'vieux/sshfs'
4848
},
4949
'_body': [{
50-
'Name': 'network',
51-
'Description': '',
52-
'Value': [
53-
'host'
54-
]
55-
}, {
56-
'Name': 'capabilities',
57-
'Description': '',
58-
'Value': [
59-
'CAP_SYS_ADMIN'
60-
]
61-
}, {
62-
'Name': 'mount',
63-
'Description': '',
64-
'Value': [
65-
'/var/lib/docker/plugins/'
66-
]
67-
}, {
68-
'Name': 'device',
69-
'Description': '',
70-
'Value': [
71-
'/dev/fuse'
72-
]
73-
}]
50+
'Name': 'network',
51+
'Description': 'permissions to access a network',
52+
'Value': ['host']
53+
},
54+
{
55+
'Name': 'mount',
56+
'Description': 'host path to mount',
57+
'Value': ['/var/lib/docker/plugins/']
58+
},
59+
{
60+
'Name': 'device',
61+
'Description': 'host device to access',
62+
'Value': ['/dev/fuse']
63+
},
64+
{
65+
'Name': 'capabilities',
66+
'Description': 'list of additional capabilities required',
67+
'Value': ['CAP_SYS_ADMIN']
68+
}
69+
]
7470
}, function(err, stream) {
7571
if (err) return done(err);
7672
stream.pipe(process.stdout);
@@ -86,19 +82,26 @@ describe("#plugin", function() {
8682
function handler(err, data) {
8783
expect(err).to.be.null;
8884
expect(data).to.be.ok;
85+
installed = true;
8986
done();
9087
}
9188

92-
plugin.enable(handler);
89+
plugin.enable({
90+
'Timeout': 5
91+
}, handler);
9392
});
9493

9594
it("should disable a plugin", function(done) {
9695
this.timeout(15000);
9796
var plugin = docker.getPlugin('sshfs');
9897

9998
function handler(err, data) {
100-
expect(err).to.be.null;
101-
expect(data).to.be.ok;
99+
if (installed === true) {
100+
expect(err).to.be.null;
101+
expect(data).to.be.ok;
102+
} else {
103+
expect(err).to.be.ok;
104+
}
102105
done();
103106
}
104107

@@ -111,11 +114,12 @@ describe("#plugin", function() {
111114

112115
function handler(err, data) {
113116
expect(err).to.be.null;
114-
expect(data).to.be.ok;
117+
expect(data).to.be.empty;
115118
done();
116119
}
117120

118121
plugin.remove(handler);
119122
});
123+
120124
});
121125
});

0 commit comments

Comments
 (0)