backtrace-morgue
Advanced tools
Comparing version 0.10.0 to 0.11.0
@@ -101,2 +101,3 @@ #!/usr/bin/env node | ||
login: coronerLogin, | ||
delete: coronerDelete, | ||
}; | ||
@@ -115,2 +116,28 @@ | ||
/** | ||
* @brief Returns the universe/project pair to use for coroner commands. | ||
*/ | ||
function coronerParams(argv, config) { | ||
var p = {}; | ||
if (Array.isArray(argv._) === true && argv._.length > 1) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
p.universe = first; | ||
p.project = argv._[1]; | ||
} else { | ||
p.universe = split[0]; | ||
p.project = split[1]; | ||
} | ||
} | ||
return p; | ||
} | ||
function saveConfig(coroner, callback) { | ||
@@ -171,4 +198,2 @@ makeConfigDir(function(err) { | ||
function coronerControl(argv, config) { | ||
var universe, project; | ||
abortIfNotLoggedIn(config); | ||
@@ -184,19 +209,2 @@ | ||
if (Array.isArray(argv._) === true && argv._.length > 1) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
if (argv.smr) { | ||
@@ -225,23 +233,6 @@ coroner.control({ 'action': 'graceperiod' }, function(error, r) { | ||
function coronerGet(argv, config) { | ||
var universe, project, object, rf; | ||
var p, object, rf; | ||
abortIfNotLoggedIn(config); | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
p = coronerParams(argv, config); | ||
object = argv._[2]; | ||
@@ -262,3 +253,3 @@ | ||
coroner.fetch(universe, project, object, rf, function(error, result) { | ||
coroner.fetch(p.universe, p.project, object, rf, function(error, result) { | ||
var output = null; | ||
@@ -285,4 +276,3 @@ | ||
var query = {}; | ||
var universe = null; | ||
var project = null; | ||
var p; | ||
var filter = null; | ||
@@ -306,23 +296,7 @@ | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
if (Array.isArray(argv._) === true && argv._[2]) | ||
filter = argv._[2]; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
if (argv._[2]) | ||
filter = argv._[2]; | ||
} | ||
coroner.describe(universe, project, function (error, result) { | ||
coroner.describe(p.universe, p.project, function (error, result) { | ||
var cd, i; | ||
@@ -388,3 +362,3 @@ var ml = 0; | ||
var formats = { 'btt' : true, 'minidump' : true, 'json' : true, 'symbols' : true }; | ||
var universe, project; | ||
var p; | ||
var concurrency = 1; | ||
@@ -414,19 +388,5 @@ var n_samples = 32; | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
p.format = argv.format; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
var files = []; | ||
@@ -486,9 +446,3 @@ | ||
coroner.put( | ||
files[bind].body, | ||
{ | ||
universe: universe, | ||
project: project, | ||
format: argv.format | ||
}, argv.compression, function(error, result) { | ||
coroner.put(files[bind].body, p, argv.compression, function(error, result) { | ||
samples.push(nsToUs(process.hrtime()) - s_st); | ||
@@ -520,10 +474,3 @@ | ||
coroner.put( | ||
files[bind].body, | ||
{ | ||
universe: universe, | ||
project: project, | ||
format: argv.format, | ||
kvs: kvs | ||
}, argv.compression, function(error, result) { | ||
coroner.put(files[bind].body, p, argv.compression, function(error, result) { | ||
if (error) { | ||
@@ -559,4 +506,3 @@ console.error((error + '').error) | ||
var query = {}; | ||
var universe = null; | ||
var project = null; | ||
var p; | ||
@@ -579,19 +525,4 @@ const insecure = !!argv.k; | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) break; | ||
universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
if (argv.reverse) | ||
@@ -796,3 +727,3 @@ reverse = -1; | ||
coroner.query(universe, project, query, function (err, result) { | ||
coroner.query(p.universe, p.project, query, function (err, result) { | ||
samples.push(result._.latency); | ||
@@ -806,3 +737,3 @@ | ||
coroner.query(universe, project, query, queryPr); | ||
coroner.query(p.universe, p.project, query, queryPr); | ||
}); | ||
@@ -812,3 +743,3 @@ })(); | ||
} else { | ||
coroner.query(universe, project, query, function (err, result) { | ||
coroner.query(p.universe, p.project, query, function (err, result) { | ||
if (err) { | ||
@@ -1263,2 +1194,39 @@ console.error(("Error: " + err.message).error); | ||
/** | ||
* @brief Implements the delete command. | ||
*/ | ||
function coronerDelete(argv, config) { | ||
const endpoint = argv._[1]; | ||
const insecure = !!argv.k; | ||
const debug = argv.debug; | ||
var o, p; | ||
abortIfNotLoggedIn(config); | ||
var coroner = new CoronerClient({ | ||
insecure: insecure, | ||
debug: debug, | ||
config: config.config, | ||
endpoint: config.endpoint, | ||
timeout: argv.timeout, | ||
}); | ||
if (argv._.length < 2) { | ||
console.error("Missing project and object ID arguments".error); | ||
return usage(); | ||
} | ||
p = coronerParams(argv, config); | ||
o = argv._.slice(2); | ||
process.stderr.write('Deleting...'.blue + '\n'); | ||
coroner.delete_objects(p.universe, p.project, o, {}, function(error, result) { | ||
if (error) { | ||
console.error((error + '').error); | ||
} else { | ||
console.log('Success'.blue); | ||
} | ||
}); | ||
} | ||
function main() { | ||
@@ -1265,0 +1233,0 @@ var argv = minimist(process.argv.slice(2), { |
@@ -95,3 +95,4 @@ #!/usr/bin/env node | ||
put: coronerPut, | ||
login: coronerLogin | ||
login: coronerLogin, | ||
delete: coronerDelete | ||
}; | ||
@@ -110,2 +111,29 @@ | ||
/** | ||
* @brief Returns the universe/project pair to use for coroner commands. | ||
*/ | ||
function coronerParams(argv, config) { | ||
var p = {}; | ||
if (Array.isArray(argv._) === true && argv._.length > 1) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}p.universe = first; | ||
p.project = argv._[1]; | ||
} else { | ||
p.universe = split[0]; | ||
p.project = split[1]; | ||
} | ||
} | ||
return p; | ||
} | ||
function saveConfig(coroner, callback) { | ||
@@ -165,4 +193,2 @@ makeConfigDir(function (err) { | ||
function coronerControl(argv, config) { | ||
var universe, project; | ||
abortIfNotLoggedIn(config); | ||
@@ -178,20 +204,2 @@ | ||
if (Array.isArray(argv._) === true && argv._.length > 1) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
if (argv.smr) { | ||
@@ -219,24 +227,6 @@ coroner.control({ 'action': 'graceperiod' }, function (error, r) { | ||
function coronerGet(argv, config) { | ||
var universe, project, object, rf; | ||
var p, object, rf; | ||
abortIfNotLoggedIn(config); | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
p = coronerParams(argv, config); | ||
object = argv._[2]; | ||
@@ -256,3 +246,3 @@ | ||
coroner.fetch(universe, project, object, rf, function (error, result) { | ||
coroner.fetch(p.universe, p.project, object, rf, function (error, result) { | ||
var output = null; | ||
@@ -277,4 +267,3 @@ | ||
var query = {}; | ||
var universe = null; | ||
var project = null; | ||
var p; | ||
var filter = null; | ||
@@ -298,23 +287,6 @@ | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
if (Array.isArray(argv._) === true && argv._[2]) filter = argv._[2]; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
if (argv._[2]) filter = argv._[2]; | ||
} | ||
coroner.describe(universe, project, function (error, result) { | ||
coroner.describe(p.universe, p.project, function (error, result) { | ||
var cd, i; | ||
@@ -374,3 +346,3 @@ var ml = 0; | ||
var formats = { 'btt': true, 'minidump': true, 'json': true, 'symbols': true }; | ||
var universe, project; | ||
var p; | ||
var concurrency = 1; | ||
@@ -400,20 +372,5 @@ var n_samples = 32; | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
p.format = argv.format; | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
var files = []; | ||
@@ -471,7 +428,3 @@ | ||
coroner.put(files[bind].body, { | ||
universe: universe, | ||
project: project, | ||
format: argv.format | ||
}, argv.compression, function (error, result) { | ||
coroner.put(files[bind].body, p, argv.compression, function (error, result) { | ||
samples.push(nsToUs(process.hrtime()) - s_st); | ||
@@ -502,8 +455,3 @@ | ||
coroner.put(files[bind].body, { | ||
universe: universe, | ||
project: project, | ||
format: argv.format, | ||
kvs: kvs | ||
}, argv.compression, function (error, result) { | ||
coroner.put(files[bind].body, p, argv.compression, function (error, result) { | ||
if (error) { | ||
@@ -536,4 +484,3 @@ console.error((error + '').error); | ||
var query = {}; | ||
var universe = null; | ||
var project = null; | ||
var p; | ||
@@ -556,20 +503,4 @@ var insecure = !!argv.k; | ||
if (Array.isArray(argv._) === true) { | ||
var split; | ||
p = coronerParams(argv, config); | ||
split = argv._[1].split('/'); | ||
if (split.length === 1) { | ||
var first; | ||
/* Try to automatically derive a path from the one argument. */ | ||
for (first in config.config.universes) { | ||
break; | ||
}universe = first; | ||
project = argv._[1]; | ||
} else { | ||
universe = split[0]; | ||
project = split[1]; | ||
} | ||
} | ||
if (argv.reverse) reverse = -1; | ||
@@ -749,3 +680,3 @@ | ||
coroner.query(universe, project, query, function (err, result) { | ||
coroner.query(p.universe, p.project, query, function (err, result) { | ||
samples.push(result._.latency); | ||
@@ -758,3 +689,3 @@ | ||
coroner.query(universe, project, query, queryPr); | ||
coroner.query(p.universe, p.project, query, queryPr); | ||
}); | ||
@@ -764,3 +695,3 @@ })(); | ||
} else { | ||
coroner.query(universe, project, query, function (err, result) { | ||
coroner.query(p.universe, p.project, query, function (err, result) { | ||
if (err) { | ||
@@ -1191,2 +1122,39 @@ console.error(("Error: " + err.message).error); | ||
/** | ||
* @brief Implements the delete command. | ||
*/ | ||
function coronerDelete(argv, config) { | ||
var endpoint = argv._[1]; | ||
var insecure = !!argv.k; | ||
var debug = argv.debug; | ||
var o, p; | ||
abortIfNotLoggedIn(config); | ||
var coroner = new CoronerClient({ | ||
insecure: insecure, | ||
debug: debug, | ||
config: config.config, | ||
endpoint: config.endpoint, | ||
timeout: argv.timeout | ||
}); | ||
if (argv._.length < 2) { | ||
console.error("Missing project and object ID arguments".error); | ||
return usage(); | ||
} | ||
p = coronerParams(argv, config); | ||
o = argv._.slice(2); | ||
process.stderr.write('Deleting...'.blue + '\n'); | ||
coroner.delete_objects(p.universe, p.project, o, {}, function (error, result) { | ||
if (error) { | ||
console.error((error + '').error); | ||
} else { | ||
console.log('Success'.blue); | ||
} | ||
}); | ||
} | ||
function main() { | ||
@@ -1193,0 +1161,0 @@ var argv = minimist(process.argv.slice(2), { |
@@ -19,2 +19,23 @@ "use strict"; | ||
CoronerClient.prototype.promise = function (name) { | ||
var fn = this[name]; | ||
if (typeof fn !== 'function') return null; | ||
var boundfn = fn.bind(this); | ||
/* Discard the name from the argument vector before passing it on. */ | ||
var args = [].slice.call(arguments); | ||
args.shift(); | ||
return new Promise(function (resolve, reject) { | ||
args.push(function (error, result) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
boundfn.apply(null, args); | ||
}); | ||
}; | ||
CoronerClient.prototype.get = function (path, params, callback) { | ||
@@ -206,2 +227,3 @@ var self = this; | ||
} catch (err) { | ||
//console.log('got bad JSON: ', text); | ||
callback(new Error("Server sent invalid JSON: " + err.message)); | ||
@@ -211,3 +233,3 @@ return; | ||
if (json.error) { | ||
var msg = json.error.message ? json.error.message : String(json.error); | ||
var msg = json.error.message ? json.error.message : json.error; | ||
callback(new Error(msg)); | ||
@@ -265,2 +287,24 @@ return; | ||
CoronerClient.prototype.delete_objects = function (universe, project, objects, params, callback) { | ||
var p = Object.assign({ | ||
universe: universe, | ||
project: project, | ||
objects: objects | ||
}, params); | ||
if (p.objects !== null) { | ||
var objs = p.objects; | ||
/* Tolerate caller arrays of number vs arrays of string etc */ | ||
if (typeof objs[0] === 'number') { | ||
objs = p.objects.map(function (x) { | ||
return x.toString(16); | ||
}); | ||
} | ||
p.objects = objs; | ||
} | ||
this.post("/api/delete", {}, p, null, callback); | ||
}; | ||
function extend(o, src) { | ||
@@ -267,0 +311,0 @@ for (var key in src) { |
{ | ||
"name": "backtrace-morgue", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "command line interface to the Backtrace object store", | ||
@@ -5,0 +5,0 @@ "main": "./dist/lib/coroner.js", |
@@ -19,2 +19,24 @@ "use strict"; | ||
CoronerClient.prototype.promise = function(name) { | ||
var fn = this[name]; | ||
if (typeof fn !== 'function') | ||
return null; | ||
var boundfn = fn.bind(this); | ||
/* Discard the name from the argument vector before passing it on. */ | ||
var args = [].slice.call(arguments); | ||
args.shift(); | ||
return new Promise(function(resolve, reject) { | ||
args.push(function(error, result) { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
boundfn.apply(null, args); | ||
}); | ||
} | ||
CoronerClient.prototype.get = function(path, params, callback) { | ||
@@ -208,2 +230,3 @@ const self = this; | ||
} catch (err) { | ||
//console.log('got bad JSON: ', text); | ||
callback(new Error("Server sent invalid JSON: " + err.message)); | ||
@@ -213,3 +236,3 @@ return; | ||
if (json.error) { | ||
let msg = json.error.message ? json.error.message : String(json.error); | ||
let msg = json.error.message ? json.error.message : json.error; | ||
callback(new Error(msg)); | ||
@@ -268,2 +291,22 @@ return; | ||
CoronerClient.prototype.delete_objects = function(universe, project, objects, params, callback) { | ||
var p = Object.assign({ | ||
universe: universe, | ||
project: project, | ||
objects: objects, | ||
}, params); | ||
if (p.objects !== null) { | ||
var objs = p.objects; | ||
/* Tolerate caller arrays of number vs arrays of string etc */ | ||
if (typeof objs[0] === 'number') { | ||
objs = p.objects.map(function(x) { return x.toString(16) }); | ||
} | ||
p.objects = objs; | ||
} | ||
this.post("/api/delete", {}, p, null, callback); | ||
}; | ||
function extend(o, src) { | ||
@@ -270,0 +313,0 @@ for (var key in src) o[key] = src[key]; |
{ | ||
"name": "backtrace-morgue", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "command line interface to the Backtrace object store", | ||
@@ -5,0 +5,0 @@ "main": "./dist/lib/coroner.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
3075
4
613233
21