Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getVmInState(opts) {
assert.object(opts, 'opts');
assert.optionalArrayOfString(opts.allowedStates, 'opts.allowedStates');
assert.optionalArrayOfString(opts.disallowedStates,
'opts.disallowedStates');
assert.ok(!(opts.allowedStates && opts.disallowedStates),
'cannot have both allowedStates and disallowedStates');
var allowed;
var disallowed;
var i;
// Convert array of allowed states into a hash, for easy lookup.
if (opts.allowedStates) {
allowed = {};
for (i = 0; i < opts.allowedStates.length; i++) {
allowed[opts.allowedStates[i]] = true;
}
}
function _addImage(img, repoTags) {
assert.optionalArrayOfString(repoTags, 'repoTags');
// reminder: img.config is the image config, img.container_config
// is the config for the container that created the image.
var imgConfig = img.config || {};
var dockerImage = {
RepoTags: (repoTags && repoTags.length
? repoTags : [':']),
Id: img.docker_id,
Created: Math.floor((new Date(img.created))
.getTime() / 1000),
Cmd: imgConfig.Cmd,
Env: imgConfig.Env,
Entrypoint: imgConfig.Entrypoint,
ParentId: img.parent || '',
Size: img.size,
Tty: imgConfig.Tty,
function cors(opts) {
assert.optionalObject(opts, 'options');
opts = opts || {};
assert.optionalArrayOfString(opts.origins, 'options.origins');
assert.optionalBool(opts.credentials, 'options.credentials');
assert.optionalArrayOfString(opts.headers, 'options.headers');
cors.credentials = opts.credentials;
cors.origins = opts.origins || ['*'];
var headers = (opts.headers || []).slice(0);
var origins = opts.origins || ['*'];
EXPOSE_HEADERS.forEach(function (h) {
if (headers.indexOf(h) === -1) {
headers.push(h);
}
});
// Handler for simple requests
function restifyCORSSimple(req, res, next) {
var origin;
Parser.prototype.parse = function parse(inputs) {
var self = this;
// Old API was `parse([argv, [slice]])`
if (Array.isArray(arguments[0])) {
inputs = {argv: arguments[0], slice: arguments[1]};
}
assert.optionalObject(inputs, 'inputs');
if (!inputs) {
inputs = {};
}
assert.optionalArrayOfString(inputs.argv, 'inputs.argv');
//assert.optionalNumber(slice, 'slice');
var argv = inputs.argv || process.argv;
var slice = inputs.slice !== undefined ? inputs.slice : 2;
var args = argv.slice(slice);
var env = inputs.env || process.env;
var opts = {};
var _order = [];
function addOpt(option, optstr, key, val, from) {
var type = optionTypes[option.type];
var parsedVal = type.parseArg(option, optstr, val);
if (type.array) {
if (!opts[key]) {
opts[key] = [];
}
if (type.arrayFlatten && Array.isArray(parsedVal)) {
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) {
var i, row;
JirashApi.prototype.search = function search(opts, cb) {
assert.object(opts, 'opts');
assert.string(opts.jql, 'opts.jql');
assert.optionalFinite(opts.startAt, 'opts.startAt');
assert.optionalFinite(opts.maxResults, 'opts.maxResults');
assert.optionalBool(opts.validateQuery, 'opts.validateQuery');
assert.optionalArrayOfString(opts.fields, 'opts.fields');
assert.optionalArrayOfString(opts.expand, 'opts.expand');
assert.func(cb, 'cb');
var context = {
api: this,
query: {
jql: opts.jql
}
};
if (has(opts, 'startAt')) {
context.query.startAt = opts.startAt;
}
if (has(opts, 'maxResults')) {
context.query.maxResults = opts.maxResults;
}
if (has(opts, 'validateQuery')) {
assert.arrayOfObject(opts.subjects, 'options.subjects');
utils.assertCompatible(opts.subjects[0], Identity, [1, 0],
'options.subjects');
utils.assertCompatible(opts.subjectKey, Key, [1, 0],
'options.subjectKey');
utils.assertCompatible(opts.issuer, Identity, [1, 0], 'options.issuer');
if (opts.issuerKey !== undefined) {
utils.assertCompatible(opts.issuerKey, Key, [1, 0],
'options.issuerKey');
}
assert.object(opts.signatures, 'options.signatures');
assert.buffer(opts.serial, 'options.serial');
assert.date(opts.validFrom, 'options.validFrom');
assert.date(opts.validUntil, 'optons.validUntil');
assert.optionalArrayOfString(opts.purposes, 'options.purposes');
this._hashCache = {};
this.subjects = opts.subjects;
this.issuer = opts.issuer;
this.subjectKey = opts.subjectKey;
this.issuerKey = opts.issuerKey;
this.signatures = opts.signatures;
this.serial = opts.serial;
this.validFrom = opts.validFrom;
this.validUntil = opts.validUntil;
this.purposes = opts.purposes;
}
JirashApi.prototype.createSearchStream = function createSearchStream(opts) {
assert.object(opts, 'opts');
assert.string(opts.jql, 'opts.jql');
assert.optionalBool(opts.validateQuery, 'opts.validateQuery');
assert.optionalArrayOfString(opts.fields, 'opts.fields');
assert.optionalArrayOfString(opts.expand, 'opts.expand');
var baseSearchOpts = {
jql: opts.jql
};
if (has(opts, 'validateQuery')) {
baseSearchOpts.validateQuery = opts.validateQuery;
}
if (opts.fields && opts.fields.length) {
baseSearchOpts.fields = opts.fields;
}
if (opts.expand && opts.expand.length) {
baseSearchOpts.expand = opts.expand;
}
var self = this;