Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function isoToMs(isoDuration) {
return toSeconds(parse(isoDuration)) * 1000;
}
};
module.exports = function restrictedDeployTimesPolicy(policy, service, options = []) {
const now = moment();
for (let { time, duration, interval } of Array.isArray(options) ? options : [options]) {
time = moment(time);
duration = moment.duration(parse(duration));
interval = interval && moment.duration(parse(interval));
while (time.isBefore(now)) {
const end = time.clone();
end.add(duration);
if (end.isAfter(now)) {
policy.fail(`Deploying on ${now.format('YYYY-MM-DD')} is not allowed`);
return;
}
if (interval) {
time.add(interval);
} else {
break;
}
}
}
module.exports = function restrictedDeployTimesPolicy(policy, service, options = []) {
const now = moment();
for (let { time, duration, interval } of Array.isArray(options) ? options : [options]) {
time = moment(time);
duration = moment.duration(parse(duration));
interval = interval && moment.duration(parse(interval));
while (time.isBefore(now)) {
const end = time.clone();
end.add(duration);
if (end.isAfter(now)) {
policy.fail(`Deploying on ${now.format('YYYY-MM-DD')} is not allowed`);
return;
}
if (interval) {
time.add(interval);
} else {
break;
}
}
}
policy.approve();