From a55860d2dfe5b014274be7db7b61d7592ce7d9fc Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Mon, 29 Jul 2019 13:47:18 +0800 Subject: [PATCH] Add property "repository" to retention task Add property "repository" to retention task Signed-off-by: Wenkai Yin --- make/migrations/postgresql/0010_1.9.0_schema.up.sql | 1 + src/pkg/retention/dao/models/retention.go | 1 + src/pkg/retention/launcher.go | 1 + src/pkg/retention/manager.go | 4 ++++ src/pkg/retention/models.go | 1 + 5 files changed, 8 insertions(+) diff --git a/make/migrations/postgresql/0010_1.9.0_schema.up.sql b/make/migrations/postgresql/0010_1.9.0_schema.up.sql index 0718b19ae..f4cb3f507 100644 --- a/make/migrations/postgresql/0010_1.9.0_schema.up.sql +++ b/make/migrations/postgresql/0010_1.9.0_schema.up.sql @@ -125,6 +125,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, diff --git a/src/pkg/retention/dao/models/retention.go b/src/pkg/retention/dao/models/retention.go index a3d24de70..5b36a212d 100644 --- a/src/pkg/retention/dao/models/retention.go +++ b/src/pkg/retention/dao/models/retention.go @@ -48,6 +48,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)"` diff --git a/src/pkg/retention/launcher.go b/src/pkg/retention/launcher.go index 6f2498c8a..4111e4300 100644 --- a/src/pkg/retention/launcher.go +++ b/src/pkg/retention/launcher.go @@ -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 { diff --git a/src/pkg/retention/manager.go b/src/pkg/retention/manager.go index 945626acc..31ff6fb1f 100644 --- a/src/pkg/retention/manager.go +++ b/src/pkg/retention/manager.go @@ -181,6 +181,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, @@ -203,6 +204,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, @@ -223,6 +225,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, @@ -242,6 +245,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, diff --git a/src/pkg/retention/models.go b/src/pkg/retention/models.go index ebbc524ad..63b544aa4 100644 --- a/src/pkg/retention/models.go +++ b/src/pkg/retention/models.go @@ -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"`