Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
2fe190f8
Commit
2fe190f8
authored
Mar 10, 2017
by
Maciej Szulik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bump(github.com/robfig/cron): 783cfcb01fb00c48f740c9de79122bd410294149
parent
6522344b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
157 additions
and
78 deletions
+157
-78
Godeps.json
Godeps/Godeps.json
+2
-2
cron.go
vendor/github.com/robfig/cron/cron.go
+10
-2
parser.go
vendor/github.com/robfig/cron/parser.go
+145
-73
spec.go
vendor/github.com/robfig/cron/spec.go
+0
-1
No files found.
Godeps/Godeps.json
View file @
2fe190f8
...
@@ -2215,8 +2215,8 @@
...
@@ -2215,8 +2215,8 @@
},
},
{
{
"ImportPath"
:
"github.com/robfig/cron"
,
"ImportPath"
:
"github.com/robfig/cron"
,
"Comment"
:
"v1-
40-g783cfcb
"
,
"Comment"
:
"v1-
53-gdf38d32
"
,
"Rev"
:
"
783cfcb01fb00c48f740c9de79122bd410294149
"
"Rev"
:
"
df38d32658d8788cd446ba74db4bb5375c4b0cb3
"
},
},
{
{
"ImportPath"
:
"github.com/rubiojr/go-vhd/vhd"
,
"ImportPath"
:
"github.com/rubiojr/go-vhd/vhd"
,
...
...
vendor/github.com/robfig/cron/cron.go
View file @
2fe190f8
// This library implements a cron spec parser and runner. See the README for
// more details.
package
cron
package
cron
import
(
import
(
...
@@ -146,6 +144,15 @@ func (c *Cron) Start() {
...
@@ -146,6 +144,15 @@ func (c *Cron) Start() {
go
c
.
run
()
go
c
.
run
()
}
}
// Run the cron scheduler, or no-op if already running.
func
(
c
*
Cron
)
Run
()
{
if
c
.
running
{
return
}
c
.
running
=
true
c
.
run
()
}
func
(
c
*
Cron
)
runWithRecovery
(
j
Job
)
{
func
(
c
*
Cron
)
runWithRecovery
(
j
Job
)
{
defer
func
()
{
defer
func
()
{
if
r
:=
recover
();
r
!=
nil
{
if
r
:=
recover
();
r
!=
nil
{
...
@@ -183,6 +190,7 @@ func (c *Cron) run() {
...
@@ -183,6 +190,7 @@ func (c *Cron) run() {
timer
:=
time
.
NewTimer
(
effective
.
Sub
(
now
))
timer
:=
time
.
NewTimer
(
effective
.
Sub
(
now
))
select
{
select
{
case
now
=
<-
timer
.
C
:
case
now
=
<-
timer
.
C
:
now
=
now
.
In
(
c
.
location
)
// Run every entry whose next time was this effective time.
// Run every entry whose next time was this effective time.
for
_
,
e
:=
range
c
.
entries
{
for
_
,
e
:=
range
c
.
entries
{
if
e
.
Next
!=
effective
{
if
e
.
Next
!=
effective
{
...
...
vendor/github.com/robfig/cron/parser.go
View file @
2fe190f8
...
@@ -8,88 +8,114 @@ import (
...
@@ -8,88 +8,114 @@ import (
"time"
"time"
)
)
// ParseStandard returns a new crontab schedule representing the given standardSpec
// Configuration options for creating a parser. Most options specify which
// (https://en.wikipedia.org/wiki/Cron). It differs from Parse requiring to always
// fields should be included, while others enable features. If a field is not
// pass 5 entries representing: minute, hour, day of month, month and day of week,
// included the parser will assume a default value. These options do not change
// in that order. It returns a descriptive error if the spec is not valid.
// the order fields are parse in.
//
type
ParseOption
int
// It accepts
// - Standard crontab specs, e.g. "* * * * ?"
// - Descriptors, e.g. "@midnight", "@every 1h30m"
func
ParseStandard
(
standardSpec
string
)
(
Schedule
,
error
)
{
if
standardSpec
[
0
]
==
'@'
{
return
parseDescriptor
(
standardSpec
)
}
// Split on whitespace. We require exactly 5 fields.
const
(
// (minute) (hour) (day of month) (month) (day of week)
Second
ParseOption
=
1
<<
iota
// Seconds field, default 0
fields
:=
strings
.
Fields
(
standardSpec
)
Minute
// Minutes field, default 0
if
len
(
fields
)
!=
5
{
Hour
// Hours field, default 0
return
nil
,
fmt
.
Errorf
(
"Expected exactly 5 fields, found %d: %s"
,
len
(
fields
),
standardSpec
)
Dom
// Day of month field, default *
}
Month
// Month field, default *
Dow
// Day of week field, default *
DowOptional
// Optional day of week field, default *
Descriptor
// Allow descriptors such as @monthly, @weekly, etc.
)
var
err
error
var
places
=
[]
ParseOption
{
field
:=
func
(
field
string
,
r
bounds
)
uint64
{
Second
,
if
err
!=
nil
{
Minute
,
return
uint64
(
0
)
Hour
,
}
Dom
,
var
bits
uint64
Month
,
bits
,
err
=
getField
(
field
,
r
)
Dow
,
return
bits
}
}
var
(
minute
=
field
(
fields
[
0
],
minutes
)
hour
=
field
(
fields
[
1
],
hours
)
dayofmonth
=
field
(
fields
[
2
],
dom
)
month
=
field
(
fields
[
3
],
months
)
dayofweek
=
field
(
fields
[
4
],
dow
)
)
if
err
!=
nil
{
return
nil
,
err
}
return
&
SpecSchedule
{
var
defaults
=
[]
string
{
Second
:
1
<<
seconds
.
min
,
"0"
,
Minute
:
minute
,
"0"
,
Hour
:
hour
,
"0"
,
Dom
:
dayofmonth
,
"*"
,
Month
:
month
,
"*"
,
Dow
:
dayofweek
,
"*"
,
},
nil
}
// A custom Parser that can be configured.
type
Parser
struct
{
options
ParseOption
optionals
int
}
// Creates a custom Parser with custom options.
//
// // Standard parser without descriptors
// specParser := NewParser(Minute | Hour | Dom | Month | Dow)
// sched, err := specParser.Parse("0 0 15 */3 *")
//
// // Same as above, just excludes time fields
// subsParser := NewParser(Dom | Month | Dow)
// sched, err := specParser.Parse("15 */3 *")
//
// // Same as above, just makes Dow optional
// subsParser := NewParser(Dom | Month | DowOptional)
// sched, err := specParser.Parse("15 */3")
//
func
NewParser
(
options
ParseOption
)
Parser
{
optionals
:=
0
if
options
&
DowOptional
>
0
{
options
|=
Dow
optionals
++
}
return
Parser
{
options
,
optionals
}
}
}
// Parse returns a new crontab schedule representing the given spec.
// Parse returns a new crontab schedule representing the given spec.
// It returns a descriptive error if the spec is not valid.
// It returns a descriptive error if the spec is not valid.
//
//
It accepts crontab specs and features configured by NewParser.
// It accepts
func
(
p
Parser
)
Parse
(
spec
string
)
(
Schedule
,
error
)
{
// - Full crontab specs, e.g. "* * * * * ?"
if
len
(
spec
)
==
0
{
// - Descriptors, e.g. "@midnight", "@every 1h30m"
return
nil
,
fmt
.
Errorf
(
"Empty spec string"
)
func
Parse
(
spec
string
)
(
Schedule
,
error
)
{
}
if
spec
[
0
]
==
'@'
{
if
spec
[
0
]
==
'@'
&&
p
.
options
&
Descriptor
>
0
{
return
parseDescriptor
(
spec
)
return
parseDescriptor
(
spec
)
}
}
// Split on whitespace. We require 5 or 6 fields.
// Figure out how many fields we need
// (second) (minute) (hour) (day of month) (month) (day of week, optional)
max
:=
0
fields
:=
strings
.
Fields
(
spec
)
for
_
,
place
:=
range
places
{
if
len
(
fields
)
!=
5
&&
len
(
fields
)
!=
6
{
if
p
.
options
&
place
>
0
{
return
nil
,
fmt
.
Errorf
(
"Expected 5 or 6 fields, found %d: %s"
,
len
(
fields
),
spec
)
max
++
}
}
}
min
:=
max
-
p
.
optionals
// If a sixth field is not provided (DayOfWeek), then it is equivalent to star.
// Split fields on whitespace
if
len
(
fields
)
==
5
{
fields
:=
strings
.
Fields
(
spec
)
fields
=
append
(
fields
,
"*"
)
// Validate number of fields
if
count
:=
len
(
fields
);
count
<
min
||
count
>
max
{
if
min
==
max
{
return
nil
,
fmt
.
Errorf
(
"Expected exactly %d fields, found %d: %s"
,
min
,
count
,
spec
)
}
return
nil
,
fmt
.
Errorf
(
"Expected %d to %d fields, found %d: %s"
,
min
,
max
,
count
,
spec
)
}
}
// Fill in missing fields
fields
=
expandFields
(
fields
,
p
.
options
)
var
err
error
var
err
error
field
:=
func
(
field
string
,
r
bounds
)
uint64
{
field
:=
func
(
field
string
,
r
bounds
)
uint64
{
if
err
!=
nil
{
if
err
!=
nil
{
return
uint64
(
0
)
return
0
}
}
var
bits
uint64
var
bits
uint64
bits
,
err
=
getField
(
field
,
r
)
bits
,
err
=
getField
(
field
,
r
)
return
bits
return
bits
}
}
var
(
var
(
second
=
field
(
fields
[
0
],
seconds
)
second
=
field
(
fields
[
0
],
seconds
)
minute
=
field
(
fields
[
1
],
minutes
)
minute
=
field
(
fields
[
1
],
minutes
)
...
@@ -112,6 +138,53 @@ func Parse(spec string) (Schedule, error) {
...
@@ -112,6 +138,53 @@ func Parse(spec string) (Schedule, error) {
},
nil
},
nil
}
}
func
expandFields
(
fields
[]
string
,
options
ParseOption
)
[]
string
{
n
:=
0
count
:=
len
(
fields
)
expFields
:=
make
([]
string
,
len
(
places
))
copy
(
expFields
,
defaults
)
for
i
,
place
:=
range
places
{
if
options
&
place
>
0
{
expFields
[
i
]
=
fields
[
n
]
n
++
}
if
n
==
count
{
break
}
}
return
expFields
}
var
standardParser
=
NewParser
(
Minute
|
Hour
|
Dom
|
Month
|
Dow
|
Descriptor
,
)
// ParseStandard returns a new crontab schedule representing the given standardSpec
// (https://en.wikipedia.org/wiki/Cron). It differs from Parse requiring to always
// pass 5 entries representing: minute, hour, day of month, month and day of week,
// in that order. It returns a descriptive error if the spec is not valid.
//
// It accepts
// - Standard crontab specs, e.g. "* * * * ?"
// - Descriptors, e.g. "@midnight", "@every 1h30m"
func
ParseStandard
(
standardSpec
string
)
(
Schedule
,
error
)
{
return
standardParser
.
Parse
(
standardSpec
)
}
var
defaultParser
=
NewParser
(
Second
|
Minute
|
Hour
|
Dom
|
Month
|
DowOptional
|
Descriptor
,
)
// Parse returns a new crontab schedule representing the given spec.
// It returns a descriptive error if the spec is not valid.
//
// It accepts
// - Full crontab specs, e.g. "* * * * * ?"
// - Descriptors, e.g. "@midnight", "@every 1h30m"
func
Parse
(
spec
string
)
(
Schedule
,
error
)
{
return
defaultParser
.
Parse
(
spec
)
}
// getField returns an Int with the bits set representing all of the times that
// getField returns an Int with the bits set representing all of the times that
// the field represents or error parsing field value. A "field" is a comma-separated
// the field represents or error parsing field value. A "field" is a comma-separated
// list of "ranges".
// list of "ranges".
...
@@ -138,18 +211,17 @@ func getRange(expr string, r bounds) (uint64, error) {
...
@@ -138,18 +211,17 @@ func getRange(expr string, r bounds) (uint64, error) {
lowAndHigh
=
strings
.
Split
(
rangeAndStep
[
0
],
"-"
)
lowAndHigh
=
strings
.
Split
(
rangeAndStep
[
0
],
"-"
)
singleDigit
=
len
(
lowAndHigh
)
==
1
singleDigit
=
len
(
lowAndHigh
)
==
1
err
error
err
error
zero
=
uint64
(
0
)
)
)
var
extra
_star
uint64
var
extra
uint64
if
lowAndHigh
[
0
]
==
"*"
||
lowAndHigh
[
0
]
==
"?"
{
if
lowAndHigh
[
0
]
==
"*"
||
lowAndHigh
[
0
]
==
"?"
{
start
=
r
.
min
start
=
r
.
min
end
=
r
.
max
end
=
r
.
max
extra
_star
=
starBit
extra
=
starBit
}
else
{
}
else
{
start
,
err
=
parseIntOrName
(
lowAndHigh
[
0
],
r
.
names
)
start
,
err
=
parseIntOrName
(
lowAndHigh
[
0
],
r
.
names
)
if
err
!=
nil
{
if
err
!=
nil
{
return
zero
,
err
return
0
,
err
}
}
switch
len
(
lowAndHigh
)
{
switch
len
(
lowAndHigh
)
{
case
1
:
case
1
:
...
@@ -157,10 +229,10 @@ func getRange(expr string, r bounds) (uint64, error) {
...
@@ -157,10 +229,10 @@ func getRange(expr string, r bounds) (uint64, error) {
case
2
:
case
2
:
end
,
err
=
parseIntOrName
(
lowAndHigh
[
1
],
r
.
names
)
end
,
err
=
parseIntOrName
(
lowAndHigh
[
1
],
r
.
names
)
if
err
!=
nil
{
if
err
!=
nil
{
return
zero
,
err
return
0
,
err
}
}
default
:
default
:
return
zero
,
fmt
.
Errorf
(
"Too many hyphens: %s"
,
expr
)
return
0
,
fmt
.
Errorf
(
"Too many hyphens: %s"
,
expr
)
}
}
}
}
...
@@ -170,7 +242,7 @@ func getRange(expr string, r bounds) (uint64, error) {
...
@@ -170,7 +242,7 @@ func getRange(expr string, r bounds) (uint64, error) {
case
2
:
case
2
:
step
,
err
=
mustParseInt
(
rangeAndStep
[
1
])
step
,
err
=
mustParseInt
(
rangeAndStep
[
1
])
if
err
!=
nil
{
if
err
!=
nil
{
return
zero
,
err
return
0
,
err
}
}
// Special handling: "N/step" means "N-max/step".
// Special handling: "N/step" means "N-max/step".
...
@@ -178,23 +250,23 @@ func getRange(expr string, r bounds) (uint64, error) {
...
@@ -178,23 +250,23 @@ func getRange(expr string, r bounds) (uint64, error) {
end
=
r
.
max
end
=
r
.
max
}
}
default
:
default
:
return
zero
,
fmt
.
Errorf
(
"Too many slashes: %s"
,
expr
)
return
0
,
fmt
.
Errorf
(
"Too many slashes: %s"
,
expr
)
}
}
if
start
<
r
.
min
{
if
start
<
r
.
min
{
return
zero
,
fmt
.
Errorf
(
"Beginning of range (%d) below minimum (%d): %s"
,
start
,
r
.
min
,
expr
)
return
0
,
fmt
.
Errorf
(
"Beginning of range (%d) below minimum (%d): %s"
,
start
,
r
.
min
,
expr
)
}
}
if
end
>
r
.
max
{
if
end
>
r
.
max
{
return
zero
,
fmt
.
Errorf
(
"End of range (%d) above maximum (%d): %s"
,
end
,
r
.
max
,
expr
)
return
0
,
fmt
.
Errorf
(
"End of range (%d) above maximum (%d): %s"
,
end
,
r
.
max
,
expr
)
}
}
if
start
>
end
{
if
start
>
end
{
return
zero
,
fmt
.
Errorf
(
"Beginning of range (%d) beyond end of range (%d): %s"
,
start
,
end
,
expr
)
return
0
,
fmt
.
Errorf
(
"Beginning of range (%d) beyond end of range (%d): %s"
,
start
,
end
,
expr
)
}
}
if
step
==
0
{
if
step
==
0
{
return
zero
,
fmt
.
Errorf
(
"Step of range should be a positive number: %s"
,
expr
)
return
0
,
fmt
.
Errorf
(
"Step of range should be a positive number: %s"
,
expr
)
}
}
return
getBits
(
start
,
end
,
step
)
|
extra
_star
,
nil
return
getBits
(
start
,
end
,
step
)
|
extra
,
nil
}
}
// parseIntOrName returns the (possibly-named) integer contained in expr.
// parseIntOrName returns the (possibly-named) integer contained in expr.
...
...
vendor/github.com/robfig/cron/spec.go
View file @
2fe190f8
...
@@ -151,7 +151,6 @@ func dayMatches(s *SpecSchedule, t time.Time) bool {
...
@@ -151,7 +151,6 @@ func dayMatches(s *SpecSchedule, t time.Time) bool {
domMatch
bool
=
1
<<
uint
(
t
.
Day
())
&
s
.
Dom
>
0
domMatch
bool
=
1
<<
uint
(
t
.
Day
())
&
s
.
Dom
>
0
dowMatch
bool
=
1
<<
uint
(
t
.
Weekday
())
&
s
.
Dow
>
0
dowMatch
bool
=
1
<<
uint
(
t
.
Weekday
())
&
s
.
Dow
>
0
)
)
if
s
.
Dom
&
starBit
>
0
||
s
.
Dow
&
starBit
>
0
{
if
s
.
Dom
&
starBit
>
0
||
s
.
Dow
&
starBit
>
0
{
return
domMatch
&&
dowMatch
return
domMatch
&&
dowMatch
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment