Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var getConfig = require('zero-config');
var grafana = require('grafana-dash-gen');
var path = require('path');
var strformat = require('strformat');
var args = process.argv.slice(2);
var configDir = __dirname;
if(args.length > 0 && args[0].length > 0 && args[0][0]!='-') {
// Use first positional argument as configDir
configDir = args[0];
}
var config = getConfig(configDir);
grafana.configure({
cookie: config.get('grafana.cookie'),
url: config.get('grafana.url')
});
function substituteVariables(vars) {
// Iteratively subsitutes variables
var doSubsitutePossible = function(vars) {
var varsDone = {};
var keys = Object.keys(vars);
var allDone = true;
for(var i = 0,length = keys.length; i < length; i++) {
if(vars[keys[i]].indexOf('{') >= 0) {
allDone = false;
} else {
varsDone[keys[i]] = vars[keys[i]];
}