(cred params.ForgeCredentials)
| 367 | } |
| 368 | |
| 369 | func formatOneGithubCredential(cred params.ForgeCredentials) { |
| 370 | if outputFormat == common.OutputFormatJSON { |
| 371 | printAsJSON(cred) |
| 372 | return |
| 373 | } |
| 374 | t := table.NewWriter() |
| 375 | header := table.Row{"Field", "Value"} |
| 376 | t.AppendHeader(header) |
| 377 | |
| 378 | var resetMinutes float64 |
| 379 | if cred.RateLimit != nil { |
| 380 | resetMinutes = cred.RateLimit.ResetIn().Minutes() |
| 381 | } |
| 382 | |
| 383 | t.AppendRow(table.Row{"ID", cred.ID}) |
| 384 | t.AppendRow(table.Row{"Created At", cred.CreatedAt}) |
| 385 | t.AppendRow(table.Row{"Updated At", cred.UpdatedAt}) |
| 386 | t.AppendRow(table.Row{"Name", cred.Name}) |
| 387 | t.AppendRow(table.Row{"Description", cred.Description}) |
| 388 | t.AppendRow(table.Row{"Base URL", cred.BaseURL}) |
| 389 | t.AppendRow(table.Row{"API URL", cred.APIBaseURL}) |
| 390 | t.AppendRow(table.Row{"Upload URL", cred.UploadBaseURL}) |
| 391 | t.AppendRow(table.Row{"Type", cred.AuthType}) |
| 392 | t.AppendRow(table.Row{"Endpoint", cred.Endpoint.Name}) |
| 393 | if resetMinutes > 0 { |
| 394 | t.AppendRow(table.Row{"", ""}) |
| 395 | t.AppendRow(table.Row{"Remaining API requests", cred.RateLimit.Remaining}) |
| 396 | t.AppendRow(table.Row{"Rate limit reset", fmt.Sprintf("%d minutes", int64(resetMinutes))}) |
| 397 | } |
| 398 | |
| 399 | if len(cred.Repositories) > 0 { |
| 400 | t.AppendRow(table.Row{"", ""}) |
| 401 | for _, repo := range cred.Repositories { |
| 402 | t.AppendRow(table.Row{"Repositories", repo.String()}) |
| 403 | } |
| 404 | } |
| 405 | |
| 406 | if len(cred.Organizations) > 0 { |
| 407 | t.AppendRow(table.Row{"", ""}) |
| 408 | for _, org := range cred.Organizations { |
| 409 | t.AppendRow(table.Row{"Organizations", org.Name}) |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | if len(cred.Enterprises) > 0 { |
| 414 | t.AppendRow(table.Row{"", ""}) |
| 415 | for _, ent := range cred.Enterprises { |
| 416 | t.AppendRow(table.Row{"Enterprises", ent.Name}) |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | t.SetColumnConfigs([]table.ColumnConfig{ |
| 421 | {Number: 1, AutoMerge: true}, |
| 422 | {Number: 2, AutoMerge: false, WidthMax: 100}, |
| 423 | }) |
| 424 | fmt.Println(t.Render()) |
| 425 | } |
no test coverage detected