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

Method ExportData

internal/codespaces/api/api.go:308–345  ·  view source on GitHub ↗
(fields []string)

Source from the content-addressed store, hash-verified

306}
307
308func (c *Codespace) ExportData(fields []string) map[string]interface{} {
309 v := reflect.ValueOf(c).Elem()
310 data := map[string]interface{}{}
311
312 for _, f := range fields {
313 switch f {
314 case "owner":
315 data[f] = c.Owner.Login
316 case "repository":
317 data[f] = c.Repository.FullName
318 case "machineName":
319 data[f] = c.Machine.Name
320 case "machineDisplayName":
321 data[f] = c.Machine.DisplayName
322 case "retentionPeriodDays":
323 data[f] = c.RetentionPeriodMinutes / 1440
324 case "gitStatus":
325 data[f] = map[string]interface{}{
326 "ref": c.GitStatus.Ref,
327 "hasUnpushedChanges": c.GitStatus.HasUnpushedChanges,
328 "hasUncommittedChanges": c.GitStatus.HasUncommittedChanges,
329 "ahead": c.GitStatus.Ahead,
330 "behind": c.GitStatus.Behind,
331 }
332 case "vscsTarget":
333 if c.VSCSTarget != "" && c.VSCSTarget != VSCSTargetProduction {
334 data[f] = c.VSCSTarget
335 }
336 default:
337 sf := v.FieldByNameFunc(func(s string) bool {
338 return strings.EqualFold(f, s)
339 })
340 data[f] = sf.Interface()
341 }
342 }
343
344 return data
345}
346
347type ListCodespacesOptions struct {
348 OrgName string

Callers 1

TestCodespace_ExportDataFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestCodespace_ExportDataFunction · 0.76