Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Parser(config) {
assert.object(config, 'config');
assert.arrayOfObject(config.options, 'config.options');
assert.optionalBool(config.interspersed, 'config.interspersed');
var self = this;
// Allow interspersed arguments (true by default).
this.interspersed = (config.interspersed !== undefined
? config.interspersed : true);
// Don't allow unknown flags (true by default).
this.allowUnknown = (config.allowUnknown !== undefined
? config.allowUnknown : false);
this.options = config.options.map(function (o) { return shallowCopy(o); });
this.optionFromName = {};
this.optionFromEnv = {};
for (var i = 0; i < this.options.length; i++) {
var o = this.options[i];
if (o.group !== undefined && o.group !== null) {
function createTestFunc(options) {
assert.object(options, 'options');
assert.optionalBool(options.checkDockerClientSupportsNfsVols,
'options.checkDockerClientSupportsNfsVols');
assert.optionalBool(options.checkTritonSupportsNfsVols,
'options.checkTritonSupportsNfsVols');
var dockerClientSupportsVols =
process.env.DOCKER_CLI_VERSION !== undefined
&& dockerClientSupportsVolumes(process.env.DOCKER_CLI_VERSION);
return function testWrapper(testName, testFunc) {
assert.string(testName, 'testName');
assert.func(testFunc, 'testFunc');
test(testName, function (t) {
if (options.checkDockerClientSupportsNfsVols
&& !dockerClientSupportsVols) {
t.ok(true,
'Docker client doesn\'t support volumes - skipping test');
t.end();
function listImagesInfo(imagesInfo, opts) {
assert.arrayOfObject(imagesInfo, 'imagesInfo');
assert.optionalObject(opts, 'opts');
if (!opts) {
opts = {};
}
assert.optionalBool(opts.json, 'opts.json');
assert.optionalBool(opts.skipHeader, 'opts.skipHeader');
assert.optionalBool(opts.docker, 'opts.docker');
assert.optionalArrayOfString(opts.columns, 'opts.columns');
assert.optionalArrayOfString(opts.sort, 'opts.sort');
if (opts.json) {
console.log(JSON.stringify(imagesInfo, null, 2));
} else {
var rows = imagesInfo.map(
function (imageInfo) { return rowFromImageInfo(imageInfo); });
/**
* `docker images`-like output:
* - only docker images
* - one row per *tag*
* - skip "non-head" images (see docker/graph/list.go)
function listImagesInfo(imagesInfo, opts) {
assert.arrayOfObject(imagesInfo, 'imagesInfo');
assert.optionalObject(opts, 'opts');
if (!opts) {
opts = {};
}
assert.optionalBool(opts.json, 'opts.json');
assert.optionalBool(opts.skipHeader, 'opts.skipHeader');
assert.optionalBool(opts.docker, 'opts.docker');
assert.optionalArrayOfString(opts.columns, 'opts.columns');
assert.optionalArrayOfString(opts.sort, 'opts.sort');
if (opts.json) {
console.log(JSON.stringify(imagesInfo, null, 2));
} else {
var rows = imagesInfo.map(
function (imageInfo) { return rowFromImageInfo(imageInfo); });
/**
* `docker images`-like output:
* - only docker images
* - one row per *tag*
* - skip "non-head" images (see docker/graph/list.go)
*/
if (opts.docker) {
self.helpSubcmds.forEach(function (sc) {
if (typeof (sc) === 'object') {
assert.string(sc.group, 'helpSubcmds.*.group');
assert.optionalBool(sc.unmatched, 'helpSubcmds.*.unmatched');
self._subcmdOrder.push(sc);
if (sc.unmatched) {
if (++unmatchCount > 1) {
throw (new Error(format('"unmatched" directive used ' +
'more than once in "helpSubcmds" option: %j', sc)));
}
/*
* Include all of the unmatched names here:
*/
while (unmatchedNames.length > 0) {
self._subcmdOrder.push(unmatchedNames.shift());
}
}
function adminImportRemoteImage(uuid, source, options, callback) {
var self = this;
if (callback === undefined) {
callback = options;
options = {};
}
assert.string(uuid, 'uuid');
assert.string(source, 'source');
assert.object(options, 'options');
assert.optionalBool(options.skipOwnerCheck, 'options.skipOwnerCheck');
assert.optionalObject(options.headers, 'options.headers');
assert.func(callback, 'callback');
var path = self._path('/images/' + uuid, {
channel: self.channel,
action: 'import-remote',
source: source,
skip_owner_check: options.skipOwnerCheck
});
self._getAuthHeaders(function (hErr, headers) {
if (hErr) {
callback(hErr);
return;
}
if (options.headers) {
simpleMerge(headers, options.headers);
function _createLinestreamParser(opts, toSocket) {
assert.object(opts, 'opts');
assert.object(opts.log, 'opts.log');
assert.object(opts.socketData, 'opts.socketData');
assert.optionalBool(opts.doNotEncodeData, 'doNotEncodeData');
assert.object(toSocket, 'toSocket');
var encodeData = !(opts.doNotEncodeData);
var lstream = new LineStream({ encoding: 'utf8' });
lstream.on('error', function (err) {
opts.log.error({ err: err }, 'LineStream threw an error');
});
lstream.on('line', function (line) {
line = line.trim();
if (!line) {
return;
}
var parsed = JSON.parse(line);
function _runAttach(opts, callback) {
assert.object(opts, 'opts');
assert.object(opts.app, 'opts.app');
assert.optionalBool(opts.doNotEncodeData, 'doNotEncodeData');
assert.optionalString(opts.id, 'opts.id');
assert.object(opts.log, 'opts.log');
assert.object(opts.socketData, 'opts.socketData');
assert.object(opts.socket, 'opts.socket');
var socketData = opts.socketData;
var host = socketData.host;
var port = socketData.port;
var clientSocket = opts.socket;
var cmdString = socketData.command.Cmd.join(' ');
var serverSocket = socketData.socket;
if (!serverSocket) {
serverSocket = net.createConnection({ host: host, port: port });
serverSocket.on('connect', setupListeners);
if (typeof (account) === 'function') {
callback = account;
options = {};
account = undefined;
} else if (typeof (account) === 'object') {
callback = options;
options = account;
account = undefined;
} else if (typeof (options) === 'function') {
callback = options;
options = {};
}
assert.optionalString(account, 'account');
assert.object(options, 'options');
assert.optionalObject(options.headers, 'options.headers');
assert.optionalBool(options.forceAllChannels, 'options.forceAllChannels');
assert.func(callback, 'callback');
var path = self._path(format('/images/%s', uuid), {
channel: self.channel,
account: account,
force_all_channels: options.forceAllChannels
});
self._getAuthHeaders(function (hErr, headers) {
if (hErr) {
callback(hErr);
return;
}
if (!headers['content-length']) {
headers['content-length'] = 0;
}
if (options.headers) {