1
1
// package schedule provides utilities for managing template and workspace
2
2
// autostart and autostop schedules. This includes utilities for parsing and
3
3
// deserializing cron-style expressions.
4
- package schedule
4
+ package cron
5
5
6
6
import (
7
7
"fmt"
8
8
"strings"
9
9
"time"
10
10
11
- "github.com/robfig/cron/v3"
11
+ rbcron "github.com/robfig/cron/v3"
12
12
"golang.org/x/xerrors"
13
13
)
14
14
15
15
// For the purposes of this library, we only need minute, hour, and
16
16
// day-of-week. However to ensure interoperability we will use the standard
17
17
// five-valued cron format. Descriptors are not supported.
18
- const parserFormat = cron .Minute | cron .Hour | cron .Dom | cron .Month | cron .Dow
18
+ const parserFormat = rbcron .Minute | rbcron .Hour | rbcron .Dom | rbcron .Month | rbcron .Dow
19
19
20
- var defaultParser = cron .NewParser (parserFormat )
20
+ var defaultParser = rbcron .NewParser (parserFormat )
21
21
22
22
// Weekly parses a Schedule from spec scoped to a recurring weekly event.
23
23
// Spec consists of the following space-delimited fields, in the following order:
@@ -30,11 +30,11 @@ var defaultParser = cron.NewParser(parserFormat)
30
30
//
31
31
// Example Usage:
32
32
//
33
- // local_sched, _ := schedule .Weekly("59 23 *")
33
+ // local_sched, _ := cron .Weekly("59 23 *")
34
34
// fmt.Println(sched.Next(time.Now().Format(time.RFC3339)))
35
35
// // Output: 2022-04-04T23:59:00Z
36
36
//
37
- // us_sched, _ := schedule .Weekly("CRON_TZ=US/Central 30 9 1-5")
37
+ // us_sched, _ := cron .Weekly("CRON_TZ=US/Central 30 9 1-5")
38
38
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
39
39
// // Output: 2022-04-04T14:30:00Z
40
40
func Weekly (raw string ) (* Schedule , error ) {
@@ -56,11 +56,11 @@ func Weekly(raw string) (*Schedule, error) {
56
56
//
57
57
// Example Usage:
58
58
//
59
- // local_sched, _ := schedule .Weekly("59 23 * * *")
59
+ // local_sched, _ := cron .Weekly("59 23 * * *")
60
60
// fmt.Println(sched.Next(time.Now().Format(time.RFC3339)))
61
61
// // Output: 2022-04-04T23:59:00Z
62
62
//
63
- // us_sched, _ := schedule .Weekly("CRON_TZ=US/Central 30 9 * * *")
63
+ // us_sched, _ := cron .Weekly("CRON_TZ=US/Central 30 9 * * *")
64
64
// fmt.Println(sched.Next(time.Now()).Format(time.RFC3339))
65
65
// // Output: 2022-04-04T14:30:00Z
66
66
func Daily (raw string ) (* Schedule , error ) {
@@ -83,7 +83,7 @@ func parse(raw string) (*Schedule, error) {
83
83
return nil , xerrors .Errorf ("parse schedule: %w" , err )
84
84
}
85
85
86
- schedule , ok := specSched .(* cron .SpecSchedule )
86
+ schedule , ok := specSched .(* rbcron .SpecSchedule )
87
87
if ! ok {
88
88
return nil , xerrors .Errorf ("expected *cron.SpecSchedule but got %T" , specSched )
89
89
}
@@ -110,7 +110,7 @@ func parse(raw string) (*Schedule, error) {
110
110
// It's essentially a wrapper for robfig/cron/v3 that has additional
111
111
// convenience methods.
112
112
type Schedule struct {
113
- sched * cron .SpecSchedule
113
+ sched * rbcron .SpecSchedule
114
114
// XXX: there isn't any nice way for robfig/cron to serialize
115
115
cronStr string
116
116
}
0 commit comments