dockerode-process
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -139,3 +139,4 @@ var EventEmitter = require('events').EventEmitter; | ||
// pull the image (or use on in the cache and output status in stdout) | ||
var pullStream = utils.streamImage(this.docker, this._createConfig.Image); | ||
var pullStream = | ||
utils.pullImageIfMissing(this.docker, this._createConfig.Image); | ||
@@ -142,0 +143,0 @@ // pipe the pull stream into stdout but don't end |
{ | ||
"name": "dockerode-process", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "ChildProcess like interface for docker containers", | ||
@@ -28,3 +28,3 @@ "main": "docker_process.js", | ||
"dockerode-promise": "0.0.1", | ||
"promise": "~3.2.0", | ||
"promise": "~5.0.0", | ||
"debug": "0.8.0" | ||
@@ -31,0 +31,0 @@ }, |
@@ -7,5 +7,5 @@ suite('docker_utils', function() { | ||
suite('#streamImage', function() { | ||
suite('#pullImageIfMissing', function() { | ||
// image with a specific tag | ||
var image = 'lightsofapollo/test-taskenv:pass'; | ||
var image = 'lightsofapollo/busybox'; | ||
setup(function() { | ||
@@ -18,3 +18,3 @@ return subject.removeImageIfExists(docker, image); | ||
function onStream() { | ||
var stream = subject.streamImage(docker, image); | ||
var stream = subject.pullImageIfMissing(docker, image); | ||
stream.resume(); | ||
@@ -33,10 +33,10 @@ | ||
test('when image does not exist', function(done) { | ||
var stream = subject.streamImage(docker, image); | ||
stream.resume(); | ||
var stream = subject.pullImageIfMissing(docker, image); | ||
stream.on('data', function() {}); | ||
//stream.resume(); | ||
stream.once('end', function() { | ||
docker.getImage(image).inspect().then( | ||
function image(result) { | ||
assert.ok(result); | ||
done(); | ||
}, | ||
docker.getImage(image).inspect().then(function image(result) { | ||
assert.ok(result); | ||
done(); | ||
}).catch( | ||
done | ||
@@ -43,0 +43,0 @@ ); |
38
utils.js
@@ -71,20 +71,20 @@ var Promise = require('promise'); | ||
@param {DockerodePromise} docker wrapper. | ||
@param {String} image docker image name. | ||
@param {Object} [options] docker pull options. | ||
@return Promise | ||
*/ | ||
function pullImage(docker, image) { | ||
function pullImage(docker, image, options) { | ||
return new Promise(function(accept, reject) { | ||
docker.pull(image).then( | ||
function(stream) { | ||
var pullStatusStream = new PullStatusStream(); | ||
stream.pipe(pullStatusStream); | ||
docker.pull(image).then(function(stream) { | ||
var pullStatusStream = new PullStatusStream(); | ||
stream.pipe(pullStatusStream); | ||
pullStatusStream.on('data', function(value) { | ||
debug('pull image', value.toString()); | ||
}); | ||
pullStatusStream.on('data', function(value) { | ||
debug('pull image', value.toString()); | ||
}); | ||
pullStatusStream.once('error', reject); | ||
pullStatusStream.once('end', accept); | ||
}, | ||
reject | ||
); | ||
pullStatusStream.once('error', reject); | ||
pullStatusStream.once('end', accept); | ||
}); | ||
}); | ||
@@ -97,5 +97,9 @@ } | ||
Returns a stream suitable for stdout for the download progress (or the cache). | ||
@return {Stream} | ||
@param {DockerodePromise} docker wrapper. | ||
@param {String} image docker image name. | ||
@param {Object} [options] docker pull options. | ||
@return {Promise[Stream]} | ||
*/ | ||
function streamImage(docker, image) { | ||
function pullImageIfMissing(docker, image, options) { | ||
debug('ensure image', image); | ||
@@ -116,3 +120,3 @@ var pullStream = new PullStatusStream(); | ||
// image is missing so pull it | ||
return docker.pull(image).then(function(rawPullStream) { | ||
return docker.pull(image, options || {}).then(function(rawPullStream) { | ||
rawPullStream.pipe(pullStream); | ||
@@ -131,2 +135,2 @@ }); | ||
module.exports.streamImage = streamImage; | ||
module.exports.pullImageIfMissing = pullImageIfMissing; |
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
18506
470
+ Addedasap@1.0.0(transitive)
+ Addedpromise@5.0.0(transitive)
Updatedpromise@~5.0.0