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