MCPcopy Create free account
hub / github.com/cli/cli / ExportData

Method ExportData

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

Source from the content-addressed store, hash-verified

319}
320
321func (c *Codespace) ExportData(fields []string) map[string]any {
322 v := reflect.ValueOf(c).Elem()
323 data := map[string]any{}
324
325 for _, f := range fields {
326 switch f {
327 case "owner":
328 data[f] = c.Owner.Login
329 case "repository":
330 data[f] = c.Repository.FullName
331 case "machineName":
332 data[f] = c.Machine.Name
333 case "machineDisplayName":
334 data[f] = c.Machine.DisplayName
335 case "retentionPeriodDays":
336 data[f] = c.RetentionPeriodMinutes / 1440
337 case "gitStatus":
338 data[f] = map[string]any{
339 "ref": c.GitStatus.Ref,
340 "hasUnpushedChanges": c.GitStatus.HasUnpushedChanges,
341 "hasUncommittedChanges": c.GitStatus.HasUncommittedChanges,
342 "ahead": c.GitStatus.Ahead,
343 "behind": c.GitStatus.Behind,
344 }
345 case "vscsTarget":
346 if c.VSCSTarget != "" && c.VSCSTarget != VSCSTargetProduction {
347 data[f] = c.VSCSTarget
348 }
349 default:
350 sf := v.FieldByNameFunc(func(s string) bool {
351 return strings.EqualFold(f, s)
352 })
353 data[f] = sf.Interface()
354 }
355 }
356
357 return data
358}
359
360type ListCodespacesOptions struct {
361 OrgName string

Callers 1

TestCodespace_ExportDataFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestCodespace_ExportDataFunction · 0.76