Skip to content

Commit eef2294

Browse files
authored
Merge pull request #2462 from actiontech/issue-ee-1592
Reduce code duplication
2 parents 784700a + 2c41ac8 commit eef2294

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

sqle/server/auditplan/task.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,9 @@ func NewDefaultTask(entry *logrus.Entry, ap *model.AuditPlan) Task {
262262
}
263263

264264
func (at *DefaultTask) Audit() (*AuditResultResp, error) {
265-
var task *model.Task
266-
if at.ap.InstanceName == "" {
267-
task = &model.Task{
268-
DBType: at.ap.DBType,
269-
}
270-
} else {
271-
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
272-
defer cancel()
273-
instance, _, err := dms.GetInstanceInProjectByName(ctx, string(at.ap.ProjectId), at.ap.InstanceName)
274-
if err != nil {
275-
return nil, err
276-
}
277-
task = &model.Task{
278-
Instance: instance,
279-
Schema: at.ap.InstanceDatabase,
280-
DBType: at.ap.DBType,
281-
}
265+
task, err := getTaskWithInstanceByAuditPlan(at.ap, at.persist)
266+
if err != nil {
267+
return nil, err
282268
}
283269
return at.baseTask.audit(task)
284270
}

0 commit comments

Comments
 (0)