Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function pushImageLayers(job, cb) {
var queue = vasync.queue(processMessage, 5);
var queueError;
// For now assume dockerUrl is the URL to the DOCKER_HOST. In this case
// we parse the URL to obtain the location of the admin host
var parsedUrl = urlModule.parse(dockerUrl);
var dockerAdminiUrl = parsedUrl.protocol + '//' + parsedUrl.hostname;
var dockerAdmin = restify.createJsonClient({
url: dockerAdminiUrl,
headers: { 'x-request-id': job.params.req_id }
});
var imgapi = new sdcClients.IMGAPI({url: imgapiUrl});
function processMessage(data, next) {
if (data.type == 'error') {
/*
* Currently WFAPI will add `err.message` and `err.name` to the
* chain_results. We'll slip our error *code* in using `err.name`.
*/
queueError = new Error(data.error.message);
if (data.error.code) {
queueError.name = data.error.code;
}
next();
'protocol': source['protocol'],
'hostname': source['host'],
'port': source['port']
});
options = {
'url': url,
'retry': false
};
for (var k in clientOptions) {
if (!options.hasOwnProperty(k))
options[k] = clientOptions[k];
}
client = mod_restify.createJsonClient(options);
client.get(path, function (err, request, response, obj) {
if (err) {
callback(err);
return;
}
if (response.statusCode != 200) {
callback(new Error('response code ' +
response.statusCode));
return;
}
callback(null, obj);
/* This could be reused. */
if (!options.userAgent) {
options.userAgent = 'restify/' + RESTIFY_VERSION + ' (' + os.arch() +
'-' + os.platform() +
'; v8/' + process.versions.v8 + '; ' +
'OpenSSL/' + process.versions.openssl + ') ' +
'node/' + process.versions.node +
'; node-smartdc/' + VERSION;
}
this.token = options.token;
if (process.env.SDC_TESTING) {
options.rejectUnauthorized = false;
}
this.client = restify.createJsonClient(options);
this.options = clone(options);
// Initialize the cache
if (!options.noCache) {
this.cacheSize = options.cacheSize || 1000;
this.cacheExpiry = (options.cacheExpiry || 60) * 1000;
this.cache = createCache(this.cacheSize);
}
}
var _ = require("underscore");
var $ = require("jquery");
/**
* Objects
*/
// create redis client
var client = redis.createClient();
// create restify server to server http api
var server = restify.createServer();
server.use(restify.bodyParser());
// create restify json client for api requests
var wikipedia = restify.createJsonClient({
url: 'http://'+config.creds.lang+'.wikipedia.org',
version: '*'
});
/**
* Run
*/
// start api requests with given keyword
wikiSearch('database');
/**
* Helper functions
*/
/**
function pullImageLayersV2(job, cb) {
var queue = vasync.queue(processMessage, 5);
var queueError;
// For now assume dockerUrl is the URL to the DOCKER_HOST. In this case
// we parse the URL to obtain the location of the admin host
var parsedUrl = urlModule.parse(dockerUrl);
var dockerAdminiUrl = parsedUrl.protocol + '//' + parsedUrl.hostname;
var dockerAdmin = restify.createJsonClient({
url: dockerAdminiUrl,
headers: { 'x-request-id': job.params.req_id }
});
var imageCreated = false;
var imgapi = new sdcClients.IMGAPI({url: imgapiUrl});
function processMessage(data, next) {
if (data.type == 'error') {
/*
* Currently WFAPI will add `err.message` and `err.name` to the
* chain_results. We'll slip our error *code* in using `err.name`.
*/
queueError = new Error(data.error.message);
if (data.error.code) {
queueError.name = data.error.code;
}
beforeEach(function () {
client = restify.createJsonClient({
url: "https://api.github.com/",
headers: {
Authorization: "token " + config.auth.github
}
});
});
githubissues: function (req, res, next) {
helpers.log("GET request for importable stories through /githubissues");
var client = restify.createJsonClient({
url: "https://api.github.com/",
headers: {
Authorization: "token " + config.auth.github
}
}),
filteredLabels = (function () {
if (config.exclude && config.exclude.labels) {
return config.exclude.labels.split(/, */);
} else {
return [];
}
}());
client.get("/repos/" + config.github.repo + "/issues", function (err, githubReq, githubRes, issues) {
helpers.log(" Received " + issues.length + " issues from GitHub");
var responseObj = {
exports.masterStop = function(hostPort, app) {
console.log('telling '+hostPort+' to tell all known peers to stop '+app);
var client = restify.createJsonClient({
url: 'http://'+hostPort,
agent: false,
version: '*'
});
client.post('/masterStop', {app: app}, function(err, req, res, data) {
if (err != null)
console.log('Error: Couldn\'t reach '+req._headers.host);
});
}
function checkHealth(_, cb) {
if (!self._healthUrl) {
return (cb());
}
var client = restify.createJsonClient({
url: self._healthUrl,
version: '*'
});
client.get('/ping', function (err, req, res, obj) {
log.info({
err: err,
obj: obj
}, 'got manatee sitter status');
if (err || (obj && !obj.healthy)) {
log.warn({err: err}, 'error fetching manatee status, ' +
'not taking snapshot.');
skipSnapshot = true;
}
return (cb());
});
},
function _watchSitter(_, _cb) {
_cb = once(_cb);
var client = restify.createJsonClient({
url: 'http://' + _.config.ip + ':' +
(_.config.postgresPort + 1),
version: '*'
});
var waitCount = 0;
var lastByte = 0;
var restoreTry = 1;
var bar, restore, lastRestore;
process.stderr.write('Watching sitter for postgres startup ');
function checkPostgresStatus() {
vasync.pipeline({ funcs: [
_getClusterStates,
_addPostgresStatus,
function _getCurrentPeer(subctx, subcb) {