@kumologica/builder
Version:
Kumologica build and deploy module
44 lines (34 loc) • 1.35 kB
JavaScript
class KumohubFlowValidator {
constructor(log) {
if (log) {
this.logger = log;
}
}
log(text, calog = true) {
if (this.logger) {
this.logger(text, calog);
} else {
console.log(text);
}
}
validate(flow) {
//const listener = flow.flow.filter(i => i.type === "EventListener" && i.provider === "kumohub");
// api
//const apis = listener.filter(i => i.keventSource == 'kapi')
// .map(a => {return {url: a.kapiUrl, verb: a.kapiMethod}});
// validate cron expressions
//const cronNodes = flow.flow.filter(i => i.type == 'KumohubListener' && i.eventType == 'cwevents');
//cronNodes.forEach (c => {
//});
// validate if aws nodes got explicit credentials only
const awsNodes = flow.filter(i => ['Rekognition', 'S3', 'SQS', 'Cloudwatch', 'Dynamo DB', 'SNS', 'SES', 'SSM'].includes(i.type));
if (awsNodes && awsNodes.length > 0) {
awsNodes.forEach(n => {
if (!n.securitytype || n.securitytype != 'Credentials') {
throw new Error (`AWS Node ${n.name} must have explicit credentials set when deploying to kumohub. Open this node and choose Credentials option.`);
}
});
}
}
}
module.exports = KumohubFlowValidator;