Merge pull request #8451 from ywk253100/190729_retention_task

Add property "repository" to retention task
This commit is contained in:
Wenkai Yin(尹文开) 2019-07-29 17:18:42 +08:00 committed by GitHub
commit 7fd06edccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 0 deletions

View File

@ -118,6 +118,7 @@ create table retention_task
(
id SERIAL NOT NULL,
execution_id integer,
repository varchar(255),
job_id varchar(64),
status varchar(32),
start_time timestamp default CURRENT_TIMESTAMP,

View File

@ -57,6 +57,7 @@ type RetentionExecution struct {
type RetentionTask struct {
ID int64 `orm:"pk;auto;column(id)"`
ExecutionID int64 `orm:"column(execution_id)"`
Repository string `orm:"column(repository)"`
JobID string `orm:"column(job_id)"`
Status string `orm:"column(status)"`
StartTime time.Time `orm:"column(start_time)"`

View File

@ -189,6 +189,7 @@ func (l *launcher) Launch(ply *policy.Metadata, executionID int64, isDryRun bool
for repo, p := range repositoryRules {
taskID, err := l.retentionMgr.CreateTask(&Task{
ExecutionID: executionID,
Repository: repo.Name,
StartTime: now,
})
if err != nil {

View File

@ -169,6 +169,7 @@ func (d *DefaultManager) CreateTask(task *Task) (int64, error) {
}
t := &models.RetentionTask{
ExecutionID: task.ExecutionID,
Repository: task.Repository,
JobID: task.JobID,
Status: task.Status,
StartTime: task.StartTime,
@ -191,6 +192,7 @@ func (d *DefaultManager) ListTasks(query ...*q.TaskQuery) ([]*Task, error) {
tasks = append(tasks, &Task{
ID: t.ID,
ExecutionID: t.ExecutionID,
Repository: t.Repository,
JobID: t.JobID,
Status: t.Status,
StartTime: t.StartTime,
@ -211,6 +213,7 @@ func (d *DefaultManager) UpdateTask(task *Task, cols ...string) error {
return dao.UpdateTask(&models.RetentionTask{
ID: task.ID,
ExecutionID: task.ExecutionID,
Repository: task.Repository,
JobID: task.JobID,
Status: task.Status,
StartTime: task.StartTime,
@ -230,6 +233,7 @@ func (d *DefaultManager) GetTask(taskID int64) (*Task, error) {
return &Task{
ID: task.ID,
ExecutionID: task.ExecutionID,
Repository: task.Repository,
JobID: task.JobID,
Status: task.Status,
StartTime: task.StartTime,

View File

@ -51,6 +51,7 @@ type Execution struct {
type Task struct {
ID int64 `json:"id"`
ExecutionID int64 `json:"execution_id"`
Repository string `json:"repository"`
JobID string `json:"job_id"`
Status string `json:"status"`
StartTime time.Time `json:"start_time"`