Skip to content

Commit b9b7a5a

Browse files
committed
remove unnecessary interface and export struct
1 parent 45253a9 commit b9b7a5a

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

coderd/crontab/crontab.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const parserFormat = cron.Minute | cron.Hour | cron.Dow
1111

1212
var defaultParser = cron.NewParser(parserFormat)
1313

14-
// WeeklySchedule represents a weekly cron schedule serializable to and from a string.
14+
// CronSchedule represents a weekly cron schedule serializable to and from a string.
1515
//
1616
// Example Usage:
1717
// local_sched, _ := cron.Parse("59 23 *")
@@ -20,31 +20,25 @@ var defaultParser = cron.NewParser(parserFormat)
2020
// us_sched, _ := cron.Parse("CRON_TZ=US/Central 30 9 1-5")
2121
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
2222
// // Output: 2022-04-04T14:30:00Z
23-
type WeeklySchedule interface {
24-
String() string
25-
Next(time.Time) time.Time
26-
}
2723

28-
// cronSchedule is a thin wrapper for cron.SpecSchedule that implements Stringer.
29-
type cronSchedule struct {
24+
// WeeklySchedule is a thin wrapper for cron.SpecSchedule that implements Stringer.
25+
type WeeklySchedule struct {
3026
sched *cron.SpecSchedule
3127
// XXX: there isn't any nice way for robfig/cron to serialize
3228
spec string
3329
}
3430

35-
var _ WeeklySchedule = (*cronSchedule)(nil)
36-
3731
// String serializes the schedule to its original human-friendly format.
38-
func (s cronSchedule) String() string {
32+
func (s WeeklySchedule) String() string {
3933
return s.spec
4034
}
4135

4236
// Next returns the next time in the schedule relative to t.
43-
func (s cronSchedule) Next(t time.Time) time.Time {
37+
func (s WeeklySchedule) Next(t time.Time) time.Time {
4438
return s.sched.Next(t)
4539
}
4640

47-
func Parse(spec string) (*cronSchedule, error) {
41+
func Parse(spec string) (*WeeklySchedule, error) {
4842
specSched, err := defaultParser.Parse(spec)
4943
if err != nil {
5044
return nil, xerrors.Errorf("parse schedule: %w", err)
@@ -55,10 +49,9 @@ func Parse(spec string) (*cronSchedule, error) {
5549
return nil, xerrors.Errorf("expected *cron.SpecSchedule but got %T", specSched)
5650
}
5751

58-
cronSched := &cronSchedule{
52+
cronSched := &WeeklySchedule{
5953
sched: schedule,
6054
spec: spec,
6155
}
6256
return cronSched, nil
63-
6457
}

coderd/crontab/crontab_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/coder/coder/coderd/crontab"
87
"github.com/stretchr/testify/require"
8+
9+
"github.com/coder/coder/coderd/crontab"
910
)
1011

1112
func Test_Parse(t *testing.T) {

0 commit comments

Comments
 (0)