muesli / beehive

A flexible event/agent & automation system with lots of bees 🐝
GNU Affero General Public License v3.0
6.32k stars 324 forks source link

Use robfig/cron to parse cron lines #327

Closed rubiojr closed 4 years ago

rubiojr commented 4 years ago

Handles parsing better, supporting the cron spec.

Partially addresses https://github.com/muesli/beehive/issues/293

rubiojr commented 4 years ago

This is ready for :eyes: now. I ran go mod tidy so the diff is a bit larger than necessary.

rubiojr commented 4 years ago

The format supported is documented in https://godoc.org/github.com/robfig/cron.

Field name   | Mandatory? | Allowed values  | Allowed special characters
----------   | ---------- | --------------  | --------------------------
Minutes      | Yes        | 0-59            | * / , -
Hours        | Yes        | 0-23            | * / , -
Day of month | Yes        | 1-31            | * / , - ?
Month        | Yes        | 1-12 or JAN-DEC | * / , -
Day of week  | Yes        | 0-6 or SUN-SAT  | * / , - ?

Tested with an old config I had around and seems to be backwards compatible. It seems to fix some issues the current parser has also, like no support for */X periods.

muesli commented 4 years ago

Fantastic!