presidium 0.16.9 → 0.16.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Docker.js +35 -0
- package/Docker.test.js +20 -1
- package/package.json +1 -1
package/Docker.js
CHANGED
|
@@ -1328,11 +1328,46 @@ Docker.prototype.createNetwork = function createNetwork(options) {
|
|
|
1328
1328
|
body: JSON.stringify(filterExists({
|
|
1329
1329
|
Name: options.name,
|
|
1330
1330
|
Driver: options.driver,
|
|
1331
|
+
Ingress: options.ingress,
|
|
1331
1332
|
CheckDuplicate: true,
|
|
1333
|
+
...options.subnet == null && options.gateway == null ? {} : {
|
|
1334
|
+
IPAM: {
|
|
1335
|
+
Driver: 'default',
|
|
1336
|
+
Config: [filterExists({
|
|
1337
|
+
Subnet: options.subnet,
|
|
1338
|
+
Gateway: options.gateway,
|
|
1339
|
+
})],
|
|
1340
|
+
Options: {},
|
|
1341
|
+
},
|
|
1342
|
+
},
|
|
1332
1343
|
})),
|
|
1333
1344
|
})
|
|
1334
1345
|
}
|
|
1335
1346
|
|
|
1347
|
+
/**
|
|
1348
|
+
* @name Docker.prototype.inspectNetwork
|
|
1349
|
+
*
|
|
1350
|
+
* @synopsis
|
|
1351
|
+
* ```coffeescript [specscript]
|
|
1352
|
+
* new Docker().inspectNetwork(id string) -> Promise<HttpResponse>
|
|
1353
|
+
* ```
|
|
1354
|
+
*/
|
|
1355
|
+
Docker.prototype.inspectNetwork = function inspectNetwork(id) {
|
|
1356
|
+
return this.http.get(`/networks/${id}`)
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* @name Docker.prototype.deleteNetwork
|
|
1361
|
+
*
|
|
1362
|
+
* @synopsis
|
|
1363
|
+
* ```coffeescript [specscript]
|
|
1364
|
+
* new Docker().deleteNetwork(id string) -> Promise<HttpResponse>
|
|
1365
|
+
* ```
|
|
1366
|
+
*/
|
|
1367
|
+
Docker.prototype.deleteNetwork = function deleteNetwork(id) {
|
|
1368
|
+
return this.http.delete(`/networks/${id}`)
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1336
1371
|
/**
|
|
1337
1372
|
* @name Docker.prototype.pruneNetworks
|
|
1338
1373
|
*
|
package/Docker.test.js
CHANGED
|
@@ -309,12 +309,26 @@ EXPOSE 8888`,
|
|
|
309
309
|
this.workerJoinToken = body.JoinTokens.Worker
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
{ // create
|
|
312
|
+
{ // create some networks
|
|
313
313
|
const response = await docker.createNetwork({
|
|
314
314
|
name: 'my-network',
|
|
315
315
|
driver: 'overlay',
|
|
316
|
+
subnet: '10.11.0.0/20',
|
|
317
|
+
gateway: '10.11.0.1',
|
|
316
318
|
})
|
|
317
319
|
assert.equal(response.status, 201)
|
|
320
|
+
|
|
321
|
+
const response2 = await docker.createNetwork({
|
|
322
|
+
name: 'my-other-network',
|
|
323
|
+
driver: 'overlay',
|
|
324
|
+
})
|
|
325
|
+
assert.equal(response2.status, 201)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
{ // inspect my-network
|
|
329
|
+
const response = await docker.inspectNetwork('my-network')
|
|
330
|
+
const network = await response.json()
|
|
331
|
+
assert.equal(network.IPAM.Config[0].Subnet, '10.11.0.0/20')
|
|
318
332
|
}
|
|
319
333
|
|
|
320
334
|
{ // create a service
|
|
@@ -420,6 +434,11 @@ EXPOSE 8888`,
|
|
|
420
434
|
assert.equal(response.status, 200)
|
|
421
435
|
}
|
|
422
436
|
|
|
437
|
+
{ // delete the network
|
|
438
|
+
const response = await docker.deleteNetwork('my-network')
|
|
439
|
+
console.log(await response.json())
|
|
440
|
+
}
|
|
441
|
+
|
|
423
442
|
await Promise.all([ // TODO figure out a real test for join. Checking for the 503 is ok but is both slow and not a 200
|
|
424
443
|
docker.joinSwarm('[::1]:2377', this.workerJoinToken, {
|
|
425
444
|
listenAddr: 'hey',
|