MCPcopy Index your code
hub / github.com/cli/cli / ExportData

Method ExportData

pkg/cmd/run/shared/shared.go:162–220  ·  view source on GitHub ↗
(fields []string)

Source from the content-addressed store, hash-verified

160}
161
162func (r *Run) ExportData(fields []string) map[string]interface{} {
163 v := reflect.ValueOf(r).Elem()
164 fieldByName := func(v reflect.Value, field string) reflect.Value {
165 return v.FieldByNameFunc(func(s string) bool {
166 return strings.EqualFold(field, s)
167 })
168 }
169 data := map[string]interface{}{}
170
171 for _, f := range fields {
172 switch f {
173 case "databaseId":
174 data[f] = r.ID
175 case "workflowDatabaseId":
176 data[f] = r.WorkflowID
177 case "workflowName":
178 data[f] = r.WorkflowName()
179 case "jobs":
180 jobs := make([]interface{}, 0, len(r.Jobs))
181 for _, j := range r.Jobs {
182 steps := make([]interface{}, 0, len(j.Steps))
183 for _, s := range j.Steps {
184 var stepCompletedAt time.Time
185 if !s.CompletedAt.IsZero() {
186 stepCompletedAt = s.CompletedAt
187 }
188 steps = append(steps, map[string]interface{}{
189 "name": s.Name,
190 "status": s.Status,
191 "conclusion": s.Conclusion,
192 "number": s.Number,
193 "startedAt": s.StartedAt,
194 "completedAt": stepCompletedAt,
195 })
196 }
197 var jobCompletedAt time.Time
198 if !j.CompletedAt.IsZero() {
199 jobCompletedAt = j.CompletedAt
200 }
201 jobs = append(jobs, map[string]interface{}{
202 "databaseId": j.ID,
203 "status": j.Status,
204 "conclusion": j.Conclusion,
205 "name": j.Name,
206 "steps": steps,
207 "startedAt": j.StartedAt,
208 "completedAt": jobCompletedAt,
209 "url": j.URL,
210 })
211 }
212 data[f] = jobs
213 default:
214 sf := fieldByName(v, f)
215 data[f] = sf.Interface()
216 }
217 }
218
219 return data

Callers

nothing calls this directly

Calls 2

WorkflowNameMethod · 0.95
fieldByNameFunction · 0.50

Tested by

no test coverage detected