node-docker-api
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -20,3 +20,3 @@ 'use strict'; | ||
var Exec = function () { | ||
function Exec(modem, container) { | ||
function Exec(modem, container, id) { | ||
_classCallCheck(this, Exec); | ||
@@ -26,2 +26,3 @@ | ||
this.container = container; | ||
this.id = id; | ||
} | ||
@@ -68,3 +69,3 @@ | ||
if (err) return reject(err); | ||
var exec = new Exec(_this.modem, conf.Id); | ||
var exec = new Exec(_this.modem, _this.container, conf.Id); | ||
resolve(Object.assign(exec, conf)); | ||
@@ -98,6 +99,8 @@ }); | ||
var call = { | ||
path: '/exec/' + id + '/start?', | ||
path: '/exec/' + id + '/start', | ||
method: 'POST', | ||
options: opts, | ||
isStream: true, | ||
hijack: opts.hijack, | ||
openStdin: opts.stdin, | ||
statusCodes: { | ||
@@ -144,3 +147,2 @@ 200: true, | ||
options: opts, | ||
isStream: true, | ||
statusCodes: { | ||
@@ -185,5 +187,4 @@ 201: true, | ||
path: '/exec/' + id + '/json?', | ||
method: 'POST', | ||
method: 'GET', | ||
options: opts, | ||
isStream: true, | ||
statusCodes: { | ||
@@ -199,3 +200,3 @@ 200: true, | ||
if (err) return reject(err); | ||
var exec = new Exec(_this4.modem, conf.Id); | ||
var exec = new Exec(_this4.modem, _this4.container, conf.Id); | ||
resolve(Object.assign(exec, conf)); | ||
@@ -214,2 +215,5 @@ }); | ||
} | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
return [opts, id]; | ||
@@ -1289,4 +1293,6 @@ } | ||
opts.container = this.id; | ||
var call = { | ||
path: '/commit?container=' + id + '&', | ||
path: '/commit?', | ||
method: 'POST', | ||
@@ -1304,3 +1310,3 @@ options: opts, | ||
if (err) return reject(err); | ||
resolve(new _image2.default(_this29.modem, res.Id)); | ||
resolve(new _image2.default(_this29.modem, res.Id.replace("sha256:", ""))); | ||
}); | ||
@@ -1318,2 +1324,5 @@ }); | ||
} | ||
if (!opts) { | ||
opts = {}; | ||
} | ||
return [opts, id]; | ||
@@ -1320,0 +1329,0 @@ } |
{ | ||
"name": "node-docker-api", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Docker Remote API driver for node", | ||
@@ -5,0 +5,0 @@ "main": "./lib/docker", |
@@ -14,3 +14,3 @@ # docker-api | ||
The current status of the package is in development. From the [API reference](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24), there's full support and test for section 3.1 and some of 3.3 (everything but commit containers, exec in containers and load and get images), experimental support for section 3.2 and the rest of 3.3. The rest of the API is still pending. | ||
The current status of the package is in development. From the [API reference](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24), there's full support and test for section 3.1 and 3.3, experimental support for section 3.2. The rest of the API is still pending. | ||
@@ -17,0 +17,0 @@ ## Installation |
@@ -6,5 +6,6 @@ 'use strict' | ||
class Exec { | ||
constructor (modem, container) { | ||
constructor (modem, container, id) { | ||
this.modem = modem | ||
this.container = container | ||
this.id = id | ||
} | ||
@@ -39,3 +40,3 @@ | ||
if (err) return reject(err) | ||
let exec = new Exec(this.modem, conf.Id) | ||
let exec = new Exec(this.modem, this.container, conf.Id) | ||
resolve(Object.assign(exec, conf)) | ||
@@ -58,6 +59,8 @@ }) | ||
const call = { | ||
path: `/exec/${id}/start?`, | ||
path: `/exec/${id}/start`, | ||
method: 'POST', | ||
options: opts, | ||
isStream: true, | ||
hijack: opts.hijack, | ||
openStdin: opts.stdin, | ||
statusCodes: { | ||
@@ -93,3 +96,2 @@ 200: true, | ||
options: opts, | ||
isStream: true, | ||
statusCodes: { | ||
@@ -123,5 +125,4 @@ 201: true, | ||
path: `/exec/${id}/json?`, | ||
method: 'POST', | ||
method: 'GET', | ||
options: opts, | ||
isStream: true, | ||
statusCodes: { | ||
@@ -137,3 +138,3 @@ 200: true, | ||
if (err) return reject(err) | ||
let exec = new Exec(this.modem, conf.Id) | ||
let exec = new Exec(this.modem, this.container, conf.Id) | ||
resolve(Object.assign(exec, conf)) | ||
@@ -151,2 +152,5 @@ }) | ||
} | ||
if (!opts) { | ||
opts = {} | ||
} | ||
return [ opts, id ] | ||
@@ -953,4 +957,6 @@ } | ||
opts.container = this.id | ||
const call = { | ||
path: `/commit?container=${id}&`, | ||
path: `/commit?`, | ||
method: 'POST', | ||
@@ -968,3 +974,3 @@ options: opts, | ||
if (err) return reject(err) | ||
resolve(new Image(this.modem, res.Id)) | ||
resolve(new Image(this.modem, res.Id.replace("sha256:", ""))) | ||
}) | ||
@@ -981,4 +987,7 @@ }) | ||
} | ||
if (!opts) { | ||
opts = {} | ||
} | ||
return [ opts, id ] | ||
} | ||
} |
import chai from 'chai' | ||
import * as test_utils from './utils' | ||
import Container from '../lib/container' | ||
import Image from '../lib/image' | ||
import {default as MemoryStream} from 'memorystream' | ||
@@ -26,2 +27,5 @@ | ||
[ 'attach', 'docker_api_test_attach' ], | ||
[ 'commit', 'docker_api_test_commit' ], | ||
[ 'exec', 'docker_api_test_exec' ], | ||
[ 'inspect_exec', 'docker_api_test_inspect_exec' ], | ||
[ 'get_archive', 'docker_api_test_get_archive' ], | ||
@@ -341,2 +345,72 @@ [ 'put_archive', 'docker_api_test_put_archive' ], | ||
describe('#commit', function () { | ||
it('should commit changes in a container', function () { | ||
this.timeout(70000) | ||
return docker.container.create({ | ||
Image: 'ubuntu', | ||
Cmd: [ '/bin/bash', '-c', 'tail -f /var/log/dmesg' ], | ||
name: containerNames.get('commit') | ||
}) | ||
.then((container) => { | ||
return container.start() | ||
}) | ||
.then((container) => { | ||
return container.commit({ comment: 'commit test' }) | ||
}) | ||
.then((image) => { | ||
image.should.be.instanceof(Image) | ||
}) | ||
}) | ||
}) | ||
describe('#exec', function () { | ||
it('should run exec on a container', function () { | ||
this.timeout(70000) | ||
return docker.container.create({ | ||
Image: 'ubuntu', | ||
Cmd: [ '/bin/bash', '-c', 'tail -f /var/log/dmesg' ], | ||
name: containerNames.get('exec') | ||
}) | ||
.then((container) => { | ||
return container.start() | ||
}) | ||
.then((container) => { | ||
return container.exec.create({ | ||
Cmd: [ "top" ] | ||
}) | ||
}) | ||
.then((exec) => { | ||
return exec.start() | ||
}) | ||
.then((stream) => { | ||
stream.pipe.should.be.ok | ||
}) | ||
}) | ||
it('should check status of exec on a container', function () { | ||
this.timeout(70000) | ||
let Exec | ||
return docker.container.create({ | ||
Image: 'ubuntu', | ||
Cmd: [ '/bin/bash', '-c', 'tail -f /var/log/dmesg' ], | ||
name: containerNames.get('inspect_exec') | ||
}) | ||
.then((container) => { | ||
return container.start() | ||
}) | ||
.then((container) => { | ||
return container.exec.create({ | ||
Cmd: [ "top" ] | ||
}) | ||
}) | ||
.then((exec) => { | ||
Exec = exec.constructor | ||
return exec.status() | ||
}) | ||
.then((exec) => { | ||
exec.should.be.instanceof(Exec) | ||
}) | ||
}) | ||
}) | ||
describe('#attach', function () { | ||
@@ -343,0 +417,0 @@ it('should attach and wait for a container', function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165725
3681