forked from goharbor/harbor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
execution.go
155 lines (138 loc) · 4.69 KB
/
execution.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package models
import (
"time"
"github.com/goharbor/harbor/src/replication/model"
)
const (
// ExecutionTable is the table name for replication executions
ExecutionTable = "replication_execution"
// TaskTable is table name for replication tasks
TaskTable = "replication_task"
)
// execution/task status/trigger const
const (
ExecutionStatusFailed string = "Failed"
ExecutionStatusSucceed string = "Succeed"
ExecutionStatusStopped string = "Stopped"
ExecutionStatusInProgress string = "InProgress"
ExecutionTriggerManual string = "Manual"
ExecutionTriggerEvent string = "Event"
ExecutionTriggerSchedule string = "Schedule"
// The task has been persisted in db but not submitted to Jobservice
TaskStatusInitialized string = "Initialized"
TaskStatusPending string = "Pending"
TaskStatusInProgress string = "InProgress"
TaskStatusSucceed string = "Succeed"
TaskStatusFailed string = "Failed"
TaskStatusStopped string = "Stopped"
)
// ExecutionPropsName defines the names of fields of Execution
var ExecutionPropsName = ExecutionFieldsName{
ID: "ID",
PolicyID: "PolicyID",
Status: "Status",
StatusText: "StatusText",
Total: "Total",
Failed: "Failed",
Succeed: "Succeed",
InProgress: "InProgress",
Stopped: "Stopped",
Trigger: "Trigger",
StartTime: "StartTime",
EndTime: "EndTime",
}
// ExecutionFieldsName defines the props of Execution
type ExecutionFieldsName struct {
ID string
PolicyID string
Status string
StatusText string
Total string
Failed string
Succeed string
InProgress string
Stopped string
Trigger string
StartTime string
EndTime string
}
// Execution holds information about once replication execution.
type Execution struct {
ID int64 `orm:"pk;auto;column(id)" json:"id"`
PolicyID int64 `orm:"column(policy_id)" json:"policy_id"`
Status string `orm:"column(status)" json:"status"`
StatusText string `orm:"column(status_text)" json:"status_text"`
Total int `orm:"column(total)" json:"total"`
Failed int `orm:"column(failed)" json:"failed"`
Succeed int `orm:"column(succeed)" json:"succeed"`
InProgress int `orm:"column(in_progress)" json:"in_progress"`
Stopped int `orm:"column(stopped)" json:"stopped"`
Trigger model.TriggerType `orm:"column(trigger)" json:"trigger"`
StartTime time.Time `orm:"column(start_time)" json:"start_time"`
EndTime time.Time `orm:"column(end_time)" json:"end_time"`
}
// TaskPropsName defines the names of fields of Task
var TaskPropsName = TaskFieldsName{
ID: "ID",
ExecutionID: "ExecutionID",
ResourceType: "ResourceType",
SrcResource: "SrcResource",
DstResource: "DstResource",
JobID: "JobID",
Status: "Status",
StartTime: "StartTime",
EndTime: "EndTime",
}
// TaskFieldsName defines the props of Task
type TaskFieldsName struct {
ID string
ExecutionID string
ResourceType string
SrcResource string
DstResource string
JobID string
Status string
StartTime string
EndTime string
}
// Task represent the tasks in one execution.
type Task struct {
ID int64 `orm:"pk;auto;column(id)" json:"id"`
ExecutionID int64 `orm:"column(execution_id)" json:"execution_id"`
ResourceType string `orm:"column(resource_type)" json:"resource_type"`
SrcResource string `orm:"column(src_resource)" json:"src_resource"`
DstResource string `orm:"column(dst_resource)" json:"dst_resource"`
Operation string `orm:"column(operation)" json:"operation"`
JobID string `orm:"column(job_id)" json:"job_id"`
Status string `orm:"column(status)" json:"status"`
StartTime *time.Time `orm:"column(start_time)" json:"start_time"`
EndTime *time.Time `orm:"column(end_time)" json:"end_time,omitempty"`
}
// TableName is required by by beego orm to map Execution to table replication_execution
func (r *Execution) TableName() string {
return ExecutionTable
}
// TableName is required by by beego orm to map Task to table replication_task
func (r *Task) TableName() string {
return TaskTable
}
// ExecutionQuery holds the query conditions for replication executions
type ExecutionQuery struct {
PolicyID int64
Statuses []string
Trigger string
Pagination
}
// TaskQuery holds the query conditions for replication task
type TaskQuery struct {
ExecutionID int64
JobID string
Statuses []string
ResourceType string
Pagination
}
// TaskStat holds statistics of task by status
type TaskStat struct {
Status string `orm:"column(status)"`
C int `orm:"column(c)"`
}