Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lines.forEach(function(line, index){
line = line.replace(/\t+/g, ' ');
var regex = /^((\@[a-zA-Z]+\s+)|(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+))/;
var command = line.replace(regex, '').trim();
var schedule = line.replace(command, '').trim();
var is_valid = false;
try { is_valid = cron_parser.parseString(line).expressions.length > 0; } catch (e){}
if(command && schedule && is_valid){
var name = namePrefix + '_' + index;
db.findOne({ command: command, schedule: schedule }, function(err, doc) {
if(err) {
throw err;
}
if(!doc){
exports.create_new(name, command, schedule, null);
}
else{
doc.command = command;
doc.schedule = schedule;
exports.update(doc);
}
get isScheduleValid(): boolean {
if (!this.kubeResource.spec.schedule) {
return false;
}
const result = cron.parseString(this.kubeResource.spec.schedule);
if (Object.keys(result.errors).length !== 0) {
return false;
}
return true;
}