/
cis_task.go
47 lines (40 loc) · 1.06 KB
/
cis_task.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package model
import (
"errors"
"time"
"github.com/KubeOperator/KubeOperator/pkg/constant"
"github.com/KubeOperator/KubeOperator/pkg/model/common"
uuid "github.com/satori/go.uuid"
)
type CisTask struct {
common.BaseModel
ID string `json:"id"`
ClusterID string `json:"clusterId"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
Policy string `json:"policy"`
Message string `json:"message" gorm:"type:text(65535)"`
//Results []CisTaskResult `json:"results"`
Status string `json:"status"`
TotalPass int `json:"totalPass"`
TotalFail int `json:"totalFail"`
TotalWarn int `json:"totalWarn"`
TotalInfo int `json:"totalInfo"`
}
func (c *CisTask) BeforeCreate() (err error) {
c.ID = uuid.NewV4().String()
return nil
}
func (c *CisTask) BeforeDelete() error {
if c.Status == constant.StatusRunning {
return errors.New("task is running")
}
return nil
}
type CisTaskWithResult struct {
CisTask
Result string `json:"_"`
}
func (CisTaskWithResult) TableName() string {
return "ko_cis_task"
}