mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-04 00:07:47 +02:00
(cherry-pick) Return time.Time{} when cron string is empty (#17290)
Return time.Time{} when cron string is empty change log level to debug to avoid noise Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
parent
0a2d091ef9
commit
d0c3463286
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user