Skip to content

refactor(coderd/schedule): move cron schedule to cron package #9507

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 2 commits into from
Sep 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rename robfig/cron import to rbcron to avoid conflict
  • Loading branch information
mafredri committed Sep 4, 2023
commit 990da42a0818595cc264dcb14d45f37a721413d0
10 changes: 5 additions & 5 deletions coderd/schedule/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ import (
"strings"
"time"

"github.com/robfig/cron/v3"
rbcron "github.com/robfig/cron/v3"
"golang.org/x/xerrors"
)

// For the purposes of this library, we only need minute, hour, and
// day-of-week. However to ensure interoperability we will use the standard
// five-valued cron format. Descriptors are not supported.
const parserFormat = cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow
const parserFormat = rbcron.Minute | rbcron.Hour | rbcron.Dom | rbcron.Month | rbcron.Dow

var defaultParser = cron.NewParser(parserFormat)
var defaultParser = rbcron.NewParser(parserFormat)

// Weekly parses a Schedule from spec scoped to a recurring weekly event.
// Spec consists of the following space-delimited fields, in the following order:
Expand Down Expand Up @@ -83,7 +83,7 @@ func parse(raw string) (*Schedule, error) {
return nil, xerrors.Errorf("parse schedule: %w", err)
}

schedule, ok := specSched.(*cron.SpecSchedule)
schedule, ok := specSched.(*rbcron.SpecSchedule)
if !ok {
return nil, xerrors.Errorf("expected *cron.SpecSchedule but got %T", specSched)
}
Expand All @@ -110,7 +110,7 @@ func parse(raw string) (*Schedule, error) {
// It's essentially a wrapper for robfig/cron/v3 that has additional
// convenience methods.
type Schedule struct {
sched *cron.SpecSchedule
sched *rbcron.SpecSchedule
// XXX: there isn't any nice way for robfig/cron to serialize
cronStr string
}
Expand Down