Skip to content

Commit

Permalink
Merge pull request #205 from zanchin/container-inspect-opts
Browse files Browse the repository at this point in the history
Allow an optional opts argument to Container.inspect
  • Loading branch information
apocas committed Jan 4, 2016
2 parents 51a1a74 + 081923c commit b056c95
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,26 @@ var Container = function(modem, id) {

/**
* Inspect
* @param {Options} opts Options (optional)
* @param {Function} callback Callback, if supplied will query Docker.
* @return {Object} ID only and only if callback isn't supplied.
*/
Container.prototype.inspect = function(callback) {
if (typeof callback === 'function') {
var optsf = {
path: '/containers/' + this.id + '/json',
method: 'GET',
statusCodes: {
200: true,
404: 'no such container',
500: 'server error'
}
};
Container.prototype.inspect = function(opts, callback) {
var args = util.processArgs(opts, callback);
var optsf = {
path: '/containers/' + this.id + '/json?',
method: 'GET',
options: args.opts,
statusCodes: {
200: true,
404: 'no such container',
500: 'server error'
}
};

if (typeof args.callback === 'function') {
this.modem.dial(optsf, function(err, data) {
callback(err, data);
args.callback(err, data);
});
} else {
return JSON.stringify({
Expand Down
12 changes: 12 additions & 0 deletions test/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ describe("#container", function() {

container.inspect(handler);
});

it("should inspect a container with opts", function(done) {
var container = docker.getContainer(testContainer);

function handler(err, data) {
expect(err).to.be.null;
expect(data).to.be.ok;
done();
}

container.inspect({}, handler);
});
});

describe("#archive", function() {
Expand Down

0 comments on commit b056c95

Please sign in to comment.