Skip to content

Commit

Permalink
Return time.Time{} when cron string is empty (goharbor#17289)
Browse files Browse the repository at this point in the history
change log level to debug to avoid noise

Signed-off-by: stonezdj <[email protected]>
Signed-off-by: Stephan Hohn <[email protected]>
  • Loading branch information
stonezdj authored and Stephan Hohn committed Feb 16, 2023
1 parent 647663c commit be75dbf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/common/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,13 @@ func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string {
// the cron string could contain 6 tokens
// if the cron string is invalid, it returns a zero time
func NextSchedule(cron string, curTime time.Time) time.Time {
if len(cron) == 0 {
return time.Time{}
}
cr := strings.TrimSpace(cron)
s, err := CronParser().Parse(cr)
if err != nil {
log.Errorf("the cron string %v is invalid, error: %v", cron, err)
log.Debugf("the cron string %v is invalid, error: %v", cron, err)
return time.Time{}
}
return s.Next(curTime)
Expand Down

0 comments on commit be75dbf

Please sign in to comment.