8000 feat: add crontab package for supporting autostart/stop. by johnstcn · Pull Request #844 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat: add crontab package for supporting autostart/stop. #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 4, 2022
Prev Previous commit
Next Next commit
fixup! feat: add crontab package for supporting autostart/stop. This …
…is basically a small wrapper around robfig/cron/v3.
  • Loading branch information
johnstcn committed Apr 4, 2022
commit b8ec4fc1faf03dfe29439c2a298593b781439636
2 changes: 1 addition & 1 deletion coderd/crontab/crontab.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var defaultParser = cron.NewParser(parserFormat)
// local_sched, _ := cron.Parse("59 23 *")
// fmt.Println(sched.Next(time.Now().Format(time.RFC3339)))
// // Output: 2022-04-04T23:59:00Z
// us_sched, _ := cron.Parse("TZ=US/Central 30 9 1-5")
// us_sched, _ := cron.Parse("CRON_TZ=US/Central 30 9 1-5")
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
// // Output: 2022-04-04T14:30:00Z
type WeeklySchedule interface {
Expand Down
4 changes: 2 additions & 2 deletions coderd/crontab/crontab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_Parse(t *testing.T) {
}{
{
name: "with timezone",
spec: "TZ=US/Central 30 9 1-5",
spec: "CRON_TZ=US/Central 30 9 1-5",
at: time.Date(2022, 4, 1, 14, 29, 0, 0, time.UTC),
expectedNext: time.Date(2022, 4, 1, 14, 30, 0, 0, time.UTC),
expectedError: "",
Expand All @@ -39,7 +39,7 @@ func Test_Parse(t *testing.T) {
},
{
name: "invalid location",
spec: "TZ=Fictional/Country 30 9 1-5",
spec: "CRON_TZ=Fictional/Country 30 9 1-5",
at: time.Time{},
expectedNext: time.Time{},
expectedError: "parse schedule: provided bad location Fictional/Country: unknown time zone Fictional/Country",
Expand Down
0