mirror of
https://github.com/goharbor/harbor.git
synced 2025-02-27 01:02:34 +01:00
fix: add "next_scheduled_time" (#18102)
Signed-off-by: Shengwen Yu <yshengwen@vmware.com>
This commit is contained in:
parent
2b82f99986
commit
94dbc3fa8f
@ -21,7 +21,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
"github.com/goharbor/harbor/src/common/utils"
|
||||
"github.com/goharbor/harbor/src/pkg/retention/dao"
|
||||
"github.com/goharbor/harbor/src/pkg/retention/dao/models"
|
||||
"github.com/goharbor/harbor/src/pkg/retention/policy"
|
||||
@ -92,6 +94,12 @@ func (d *DefaultManager) GetPolicy(ctx context.Context, id int64) (*policy.Metad
|
||||
return nil, err
|
||||
}
|
||||
p.ID = id
|
||||
if p.Trigger.Kind == policy.TriggerKindSchedule {
|
||||
cron, ok := p.Trigger.Settings[policy.TriggerSettingsCron]
|
||||
if ok && len(cron.(string)) > 0 {
|
||||
p.Trigger.Settings[policy.TriggerSettingNextScheduledTime] = strfmt.DateTime(utils.NextSchedule(cron.(string), time.Now()))
|
||||
}
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@ const (
|
||||
// TriggerSettingsCron cron
|
||||
TriggerSettingsCron = "cron"
|
||||
|
||||
// TriggerSettingNextScheduledTime next_scheduled_time
|
||||
TriggerSettingNextScheduledTime = "next_scheduled_time"
|
||||
|
||||
// ScopeLevelProject project
|
||||
ScopeLevelProject = "project"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user