@@ -39,6 +39,8 @@ type UserTask struct {
39
39
State string `json:"state,omitempty"`
40
40
// IssueType identifies this task's issue type.
41
41
IssueType string `json:"issueType,omitempty"`
42
+ // Title is the issue title.
43
+ Title string `json:"title,omitempty"`
42
44
// Integration is the Integration Name this User Task refers to.
43
45
Integration string `json:"integration,omitempty"`
44
46
// LastStateChange indicates when the current's user task state was last changed.
@@ -49,8 +51,6 @@ type UserTask struct {
49
51
type UserTaskDetail struct {
50
52
// UserTask has the basic fields that all tasks include.
51
53
UserTask
52
- // Title is the issue title.
53
- Title string `json:"title,omitempty"`
54
54
// Description is a markdown document that explains the issue and how to fix it.
55
55
Description string `json:"description,omitempty"`
56
56
// DiscoverEC2 contains the task details for the DiscoverEC2 tasks.
@@ -99,44 +99,57 @@ func MakeUserTasks(uts []*usertasksv1.UserTask) []UserTask {
99
99
100
100
// MakeDetailedUserTask creates a UI UserTask representation containing all the details.
101
101
func MakeDetailedUserTask (ut * usertasksv1.UserTask ) UserTaskDetail {
102
- var title string
103
- var description string
104
-
105
102
var discoverEC2 * usertasks.UserTaskDiscoverEC2WithURLs
106
103
var discoverEKS * usertasks.UserTaskDiscoverEKSWithURLs
107
104
var discoverRDS * usertasks.UserTaskDiscoverRDSWithURLs
108
105
109
106
switch ut .GetSpec ().GetTaskType () {
110
107
case apiusertasks .TaskTypeDiscoverEC2 :
111
- title , description = usertasks .DescriptionForDiscoverEC2Issue (ut .GetSpec ().GetIssueType ())
112
108
discoverEC2 = usertasks .EC2InstancesWithURLs (ut )
113
109
114
110
case apiusertasks .TaskTypeDiscoverEKS :
115
- title , description = usertasks .DescriptionForDiscoverEKSIssue (ut .GetSpec ().GetIssueType ())
116
111
discoverEKS = usertasks .EKSClustersWithURLs (ut )
117
112
118
113
case apiusertasks .TaskTypeDiscoverRDS :
119
- title , description = usertasks .DescriptionForDiscoverRDSIssue (ut .GetSpec ().GetIssueType ())
120
114
discoverRDS = usertasks .RDSDatabasesWithURLs (ut )
121
115
}
122
116
117
+ _ , description := userTaskTitleAndDescription (ut )
118
+
123
119
return UserTaskDetail {
124
120
UserTask : MakeUserTask (ut ),
125
- Title : title ,
126
121
Description : description ,
127
122
DiscoverEC2 : discoverEC2 ,
128
123
DiscoverEKS : discoverEKS ,
129
124
DiscoverRDS : discoverRDS ,
130
125
}
131
126
}
132
127
128
+ func userTaskTitleAndDescription (ut * usertasksv1.UserTask ) (string , string ) {
129
+ switch ut .GetSpec ().GetTaskType () {
130
+ case apiusertasks .TaskTypeDiscoverEC2 :
131
+ return usertasks .DescriptionForDiscoverEC2Issue (ut .GetSpec ().GetIssueType ())
132
+
133
+ case apiusertasks .TaskTypeDiscoverEKS :
134
+ return usertasks .DescriptionForDiscoverEKSIssue (ut .GetSpec ().GetIssueType ())
135
+
136
+ case apiusertasks .TaskTypeDiscoverRDS :
137
+ return usertasks .DescriptionForDiscoverRDSIssue (ut .GetSpec ().GetIssueType ())
138
+
139
+ default :
140
+ return "" , ""
141
+ }
142
+ }
143
+
133
144
// MakeUserTask creates a UI UserTask representation.
134
145
func MakeUserTask (ut * usertasksv1.UserTask ) UserTask {
146
+ title , _ := userTaskTitleAndDescription (ut )
135
147
return UserTask {
136
148
Name : ut .GetMetadata ().GetName (),
137
149
TaskType : ut .GetSpec ().GetTaskType (),
138
150
State : ut .GetSpec ().GetState (),
139
151
IssueType : ut .GetSpec ().GetIssueType (),
152
+ Title : title ,
140
153
Integration : ut .GetSpec ().GetIntegration (),
141
154
LastStateChange : ut .GetStatus ().GetLastStateChange ().AsTime (),
142
155
}
0 commit comments