Skip to content

Commit fe400c5

Browse files
committed
1.0.5 network ls
1 parent 515c572 commit fe400c5

4 files changed

Lines changed: 108 additions & 26 deletions

File tree

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ docker.command('images').then(function (data) {
179179
});
180180

181181

182-
data = { command: 'docker images ',
182+
//data = { command: 'docker images ',
183183
// raw: '["REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE\\nquobjectio/consul
184184
// 0.5.2 c2e8640282e5 5 days ago 37.17 MB\\nquobjectio/consul 0.5.2c 74ae12b3b517 5 days ago 35.92 MB\\n<none> <none> 35682216ba6f 6 days ago
185185
//35.92 MB\\nquobjectio/mongodb 3.0.7 5ca1d18839fb 10 days ago 347 MB\\nquobjectio/mongodb
@@ -251,4 +251,50 @@ data = { command: 'docker images ',
251251
// 'image id': 'e27c5e60a8f1',
252252
// created: '5 months ago',
253253
// 'virtual size': '502.6 MB' } ] }
254+
```
255+
256+
* docker images
257+
258+
```js
259+
260+
docker.command('network ls').then(function (data) {
261+
console.log('data = ', data);
262+
});
263+
264+
265+
//data = {
266+
// command: 'docker network ls ',
267+
// raw: '["NETWORK ID NAME DRIVER\\n4d6a0a35e87f machine.1.ap-southeast-2.1.0.0.5/none null \\n042642d752f4 machine.1.ap-southeast-2.1.0.0.5/host host \\n6cc7e229d7c3 machine.1.ap-southeast-2.2.0.0.5/none null \\n4a6e627fc1dc machine.1.ap-southeast-2.2.0.0.5/host host \\ne1b70f5af1c8 machine.1.ap-southeast-2.2.0.0.5/bridge bridge \\n1f5d449aca44 machine.1.ap-southeast-2.1.0.0.5/bridge bridge \\n",""]',
268+
// network:
269+
// [{
270+
// 'network id': '4d6a0a35e87f',
271+
// name: 'machine.1.ap-southeast-2.1.0.0.5/none',
272+
// driver: 'null'
273+
// },
274+
// {
275+
// 'network id': '042642d752f4',
276+
// name: 'machine.1.ap-southeast-2.1.0.0.5/host',
277+
// driver: 'host'
278+
// },
279+
// {
280+
// 'network id': '6cc7e229d7c3',
281+
// name: 'machine.1.ap-southeast-2.2.0.0.5/none',
282+
// driver: 'null'
283+
// },
284+
// {
285+
// 'network id': '4a6e627fc1dc',
286+
// name: 'machine.1.ap-southeast-2.2.0.0.5/host',
287+
// driver: 'host'
288+
// },
289+
// {
290+
// 'network id': 'e1b70f5af1c8',
291+
// name: 'machine.1.ap-southeast-2.2.0.0.5/bridge',
292+
// driver: 'bridge'
293+
// },
294+
// {
295+
// 'network id': '1f5d449aca44',
296+
// name: 'machine.1.ap-southeast-2.1.0.0.5/bridge',
297+
// driver: 'bridge'
298+
// }]
299+
//}
254300
```

lib/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ var extractResult = function (result) {
142142
//debug(lines);
143143
resultp.images = cliTable2Json(lines);
144144

145+
return resultp;
146+
},
147+
},
148+
{
149+
re: / network ls /,
150+
run: function (resultp) {
151+
var obj = JSON.parse(resultp.raw);
152+
var lines = obj[0].split(os.EOL);
153+
154+
//var debug = require('debug')('docker-cli-js:lib/index.js extractResult images');
155+
//debug(lines);
156+
resultp.network = cliTable2Json(lines);
157+
145158
return resultp;
146159
}
147160
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docker-cli-js",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "A wrapper for the docker CLI",
55
"main": "lib/index.js",
66
"scripts": {

test/index.js

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,30 +135,30 @@ describe('docker', function () {
135135
// });
136136
//});
137137

138-
it('command ps', function (done) {
139-
this.timeout(15000);
140-
var docker = new Docker({
141-
machinename: config.DockerMachineName,
142-
});
143-
console.log('docker', docker);
144-
assert.isNotNull(docker);
145-
var failed = false;
146-
var err = null;
147-
docker.command('ps').then(function (data) {
148-
console.log('data = ', data);
149-
assert.isNotNull(data);
150-
}).catch(function (error) {
151-
assert.isNotNull(error);
152-
err = error;
153-
failed = true;
154-
console.log('error = ', error);
155-
}).finally(function () {
156-
console.log('finally ');
157-
assert.isFalse(failed);
158-
assert.isNull(err);
159-
done();
160-
});
161-
});
138+
//it('command ps', function (done) {
139+
// this.timeout(15000);
140+
// var docker = new Docker({
141+
// machinename: config.DockerMachineName,
142+
// });
143+
// console.log('docker', docker);
144+
// assert.isNotNull(docker);
145+
// var failed = false;
146+
// var err = null;
147+
// docker.command('ps').then(function (data) {
148+
// console.log('data = ', data);
149+
// assert.isNotNull(data);
150+
// }).catch(function (error) {
151+
// assert.isNotNull(error);
152+
// err = error;
153+
// failed = true;
154+
// console.log('error = ', error);
155+
// }).finally(function () {
156+
// console.log('finally ');
157+
// assert.isFalse(failed);
158+
// assert.isNull(err);
159+
// done();
160+
// });
161+
//});
162162

163163

164164
//it('command images', function (done) {
@@ -186,6 +186,29 @@ describe('docker', function () {
186186
// });
187187
//});
188188

189+
it('command network ls', function (done) {
190+
this.timeout(15000);
191+
var docker = new Docker({});
192+
assert.isNotNull(docker);
193+
var failed = false;
194+
var err = null;
195+
docker.command('--tlsverify --tlscacert="/home/apollo/.docker/machine/certs/ca.pem" --tlscert="/home/apollo/.docker/machine/certs/cert.pem" --tlskey="/home/apollo/.docker/machine/certs/key.pem" -H=tcp://52.62.82.61:3376 network ls').then(function (data) {
196+
console.log('data = ', data);
197+
assert.isNotNull(data);
198+
}).catch(function (error) {
199+
assert.isNotNull(error);
200+
err = error;
201+
failed = true;
202+
console.log('error = ', error);
203+
}).finally(function () {
204+
console.log('finally ');
205+
assert.isFalse(failed);
206+
assert.isNull(err);
207+
done();
208+
});
209+
});
210+
211+
189212
});
190213

191214

0 commit comments

Comments
 (0)