(batchAPI schema.APIResponse)
| 85 | } |
| 86 | |
| 87 | func batchAPITable(batchAPI schema.APIResponse) string { |
| 88 | jobRows := make([][]interface{}, 0, len(batchAPI.BatchJobStatuses)) |
| 89 | |
| 90 | out := "" |
| 91 | if len(batchAPI.BatchJobStatuses) == 0 { |
| 92 | out = console.Bold("no submitted batch jobs\n") |
| 93 | } else { |
| 94 | for _, job := range batchAPI.BatchJobStatuses { |
| 95 | |
| 96 | jobEndTime := time.Now() |
| 97 | if job.EndTime != nil { |
| 98 | jobEndTime = *job.EndTime |
| 99 | } |
| 100 | |
| 101 | duration := jobEndTime.Sub(job.StartTime).Truncate(time.Second).String() |
| 102 | |
| 103 | jobRows = append(jobRows, []interface{}{ |
| 104 | job.ID, |
| 105 | job.Status.Message(), |
| 106 | job.TotalBatchCount, |
| 107 | job.StartTime.Format(_timeFormat), |
| 108 | duration, |
| 109 | }) |
| 110 | } |
| 111 | |
| 112 | t := table.Table{ |
| 113 | Headers: []table.Header{ |
| 114 | {Title: "job id"}, |
| 115 | {Title: "status"}, |
| 116 | {Title: "total batches"}, |
| 117 | {Title: "start time"}, |
| 118 | {Title: "duration"}, |
| 119 | }, |
| 120 | Rows: jobRows, |
| 121 | } |
| 122 | |
| 123 | out += t.MustFormat() |
| 124 | } |
| 125 | |
| 126 | if batchAPI.DashboardURL != nil && *batchAPI.DashboardURL != "" { |
| 127 | out += "\n" + console.Bold("metrics dashboard: ") + *batchAPI.DashboardURL + "\n" |
| 128 | } |
| 129 | |
| 130 | if batchAPI.Endpoint != nil { |
| 131 | out += "\n" + console.Bold("endpoint: ") + *batchAPI.Endpoint + "\n" |
| 132 | } |
| 133 | |
| 134 | out += "\n" + apiHistoryTable(batchAPI.APIVersions) |
| 135 | |
| 136 | if !_flagVerbose { |
| 137 | return out |
| 138 | } |
| 139 | |
| 140 | out += titleStr("batch api configuration") + batchAPI.Spec.UserStr() |
| 141 | |
| 142 | return out |
| 143 | } |
| 144 |
no test coverage detected