(pools []params.Pool)
| 658 | } |
| 659 | |
| 660 | func formatPools(pools []params.Pool) { |
| 661 | if outputFormat == common.OutputFormatJSON { |
| 662 | printAsJSON(pools) |
| 663 | return |
| 664 | } |
| 665 | t := table.NewWriter() |
| 666 | t.SetColumnConfigs([]table.ColumnConfig{ |
| 667 | {Number: 2, WidthMax: 40}, |
| 668 | }) |
| 669 | header := table.Row{"ID", "Image", "Flavor", "Tags", "Belongs to", "Endpoint", "Forge Type", "Enabled"} |
| 670 | if long { |
| 671 | header = append(header, "Level", "Created At", "Updated at", "Runner Prefix", "Priority") |
| 672 | } |
| 673 | t.AppendHeader(header) |
| 674 | |
| 675 | for _, pool := range pools { |
| 676 | tags := []string{} |
| 677 | for _, tag := range pool.Tags { |
| 678 | tags = append(tags, tag.Name) |
| 679 | } |
| 680 | var belongsTo string |
| 681 | var level string |
| 682 | |
| 683 | switch { |
| 684 | case pool.RepoID != "" && pool.RepoName != "": |
| 685 | belongsTo = pool.RepoName |
| 686 | level = entityTypeRepo |
| 687 | case pool.OrgID != "" && pool.OrgName != "": |
| 688 | belongsTo = pool.OrgName |
| 689 | level = entityTypeOrg |
| 690 | case pool.EnterpriseID != "" && pool.EnterpriseName != "": |
| 691 | belongsTo = pool.EnterpriseName |
| 692 | level = entityTypeEnterprise |
| 693 | } |
| 694 | row := table.Row{pool.ID, pool.Image, pool.Flavor, strings.Join(tags, " "), belongsTo, pool.Endpoint.Name, pool.Endpoint.EndpointType, pool.Enabled} |
| 695 | if long { |
| 696 | row = append(row, level, pool.CreatedAt, pool.UpdatedAt, pool.GetRunnerPrefix(), pool.Priority) |
| 697 | } |
| 698 | t.AppendRow(row) |
| 699 | t.AppendSeparator() |
| 700 | } |
| 701 | fmt.Println(t.Render()) |
| 702 | } |
| 703 | |
| 704 | func formatOnePool(pool params.Pool) { |
| 705 | if outputFormat == common.OutputFormatJSON { |
no test coverage detected