mirror of
https://github.com/goharbor/harbor
synced 2025-05-18 15:49:02 +00:00
Return time.Time{} when cron string is empty (#17289)
change log level to debug to avoid noise Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
parent
b4f2f170b4
commit
66d34c8e0c
@ -284,10 +284,13 @@ func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string {
|
|||||||
// the cron string could contain 6 tokens
|
// the cron string could contain 6 tokens
|
||||||
// if the cron string is invalid, it returns a zero time
|
// if the cron string is invalid, it returns a zero time
|
||||||
func NextSchedule(cron string, curTime time.Time) time.Time {
|
func NextSchedule(cron string, curTime time.Time) time.Time {
|
||||||
|
if len(cron) == 0 {
|
||||||
|
return time.Time{}
|
||||||
|
}
|
||||||
cr := strings.TrimSpace(cron)
|
cr := strings.TrimSpace(cron)
|
||||||
s, err := CronParser().Parse(cr)
|
s, err := CronParser().Parse(cr)
|
||||||
if err != nil {
|
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 time.Time{}
|
||||||
}
|
}
|
||||||
return s.Next(curTime)
|
return s.Next(curTime)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user