(env cliconfig.Environment, apiName string, jobID string)
| 143 | } |
| 144 | |
| 145 | func getBatchJob(env cliconfig.Environment, apiName string, jobID string) (string, error) { |
| 146 | resp, err := cluster.GetBatchJob(MustGetOperatorConfig(env.Name), apiName, jobID) |
| 147 | if err != nil { |
| 148 | return "", err |
| 149 | } |
| 150 | |
| 151 | var bytes []byte |
| 152 | if _flagOutput == flags.JSONOutputType { |
| 153 | bytes, err = libjson.Marshal(resp) |
| 154 | } else if _flagOutput == flags.YAMLOutputType { |
| 155 | bytes, err = yaml.Marshal(resp) |
| 156 | } |
| 157 | if err != nil { |
| 158 | return "", err |
| 159 | } |
| 160 | if _flagOutput == flags.JSONOutputType || _flagOutput == flags.YAMLOutputType { |
| 161 | return string(bytes), nil |
| 162 | } |
| 163 | |
| 164 | job := resp.JobStatus |
| 165 | |
| 166 | out := "" |
| 167 | |
| 168 | jobIntroTable := table.KeyValuePairs{} |
| 169 | jobIntroTable.Add("job id", job.ID) |
| 170 | jobIntroTable.Add("status", job.Status.Message()) |
| 171 | out += jobIntroTable.String(&table.KeyValuePairOpts{BoldKeys: pointer.Bool(true)}) |
| 172 | |
| 173 | jobTimingTable := table.KeyValuePairs{} |
| 174 | jobTimingTable.Add("start time", job.StartTime.Format(_timeFormat)) |
| 175 | |
| 176 | jobEndTime := time.Now() |
| 177 | if job.EndTime != nil { |
| 178 | jobTimingTable.Add("end time", job.EndTime.Format(_timeFormat)) |
| 179 | jobEndTime = *job.EndTime |
| 180 | } else { |
| 181 | jobTimingTable.Add("end time", "-") |
| 182 | } |
| 183 | duration := jobEndTime.Sub(job.StartTime).Truncate(time.Second).String() |
| 184 | jobTimingTable.Add("duration", duration) |
| 185 | |
| 186 | out += "\n" + jobTimingTable.String(&table.KeyValuePairOpts{BoldKeys: pointer.Bool(true)}) |
| 187 | |
| 188 | succeeded := "-" |
| 189 | failed := "-" |
| 190 | avgTimePerBatch := "-" |
| 191 | |
| 192 | if resp.Metrics != nil { |
| 193 | if resp.Metrics.AverageTimePerBatch != nil { |
| 194 | batchMetricsDuration := time.Duration(*resp.Metrics.AverageTimePerBatch*1000000000) * time.Nanosecond |
| 195 | avgTimePerBatch = batchMetricsDuration.Truncate(time.Millisecond).String() |
| 196 | } |
| 197 | |
| 198 | succeeded = s.Int(resp.Metrics.Succeeded) |
| 199 | failed = s.Int(resp.Metrics.Failed) |
| 200 | } |
| 201 | |
| 202 | t := table.Table{ |
no test coverage detected