Skip to content

Commit

Permalink
Merge pull request #2462 from actiontech/issue-ee-1592
Browse files Browse the repository at this point in the history
Reduce code duplication
  • Loading branch information
taolx0 committed Jun 20, 2024
2 parents 784700a + 2c41ac8 commit eef2294
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions sqle/server/auditplan/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,9 @@ func NewDefaultTask(entry *logrus.Entry, ap *model.AuditPlan) Task {
}

func (at *DefaultTask) Audit() (*AuditResultResp, error) {
var task *model.Task
if at.ap.InstanceName == "" {
task = &model.Task{
DBType: at.ap.DBType,
}
} else {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
defer cancel()
instance, _, err := dms.GetInstanceInProjectByName(ctx, string(at.ap.ProjectId), at.ap.InstanceName)
if err != nil {
return nil, err
}
task = &model.Task{
Instance: instance,
Schema: at.ap.InstanceDatabase,
DBType: at.ap.DBType,
}
task, err := getTaskWithInstanceByAuditPlan(at.ap, at.persist)
if err != nil {
return nil, err
}
return at.baseTask.audit(task)
}
Expand Down

0 comments on commit eef2294

Please sign in to comment.