move formatUnixNanoTime into a utility function
This commit is contained in:
parent
5ce7b308bb
commit
e0d757b7b0
|
@ -194,7 +194,7 @@ func (c *AllocStatusCommand) outputTaskStatus(state *api.TaskState) {
|
|||
|
||||
size := len(state.Events)
|
||||
for i, event := range state.Events {
|
||||
formatedTime := c.formatUnixNanoTime(event.Time)
|
||||
formatedTime := formatUnixNanoTime(event.Time)
|
||||
|
||||
// Build up the description based on the event type.
|
||||
var desc string
|
||||
|
@ -400,7 +400,7 @@ func (c *AllocStatusCommand) shortTaskStatus(alloc *api.Allocation) {
|
|||
if l != 0 {
|
||||
last := state.Events[l-1]
|
||||
lastEvent = last.Type
|
||||
lastTime = c.formatUnixNanoTime(last.Time)
|
||||
lastTime = formatUnixNanoTime(last.Time)
|
||||
}
|
||||
|
||||
tasks = append(tasks, fmt.Sprintf("%s|%s|%s|%s",
|
||||
|
@ -430,9 +430,3 @@ func (c *AllocStatusCommand) sortedTaskStateIterator(m map[string]*api.TaskState
|
|||
close(output)
|
||||
return output
|
||||
}
|
||||
|
||||
// formatUnixNanoTime is a helper for formating time for output.
|
||||
func (c *AllocStatusCommand) formatUnixNanoTime(nano int64) string {
|
||||
t := time.Unix(0, nano)
|
||||
return formatTime(t)
|
||||
}
|
||||
|
|
|
@ -51,6 +51,12 @@ func formatTime(t time.Time) string {
|
|||
return t.Format("01/02/06 15:04:05 MST")
|
||||
}
|
||||
|
||||
// formatUnixNanoTime is a helper for formatting time for output.
|
||||
func formatUnixNanoTime(nano int64) string {
|
||||
t := time.Unix(0, nano)
|
||||
return formatTime(t)
|
||||
}
|
||||
|
||||
// formatTimeDifference takes two times and determines their duration difference
|
||||
// truncating to a passed unit.
|
||||
// E.g. formatTimeDifference(first=1m22s33ms, second=1m28s55ms, time.Second) -> 6s
|
||||
|
|
|
@ -310,7 +310,7 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
|
|||
alloc.TaskGroup,
|
||||
alloc.DesiredStatus,
|
||||
alloc.ClientStatus,
|
||||
c.formatUnixNanoTime(alloc.CreateTime))
|
||||
formatUnixNanoTime(alloc.CreateTime))
|
||||
}
|
||||
|
||||
c.Ui.Output(formatList(allocs))
|
||||
|
@ -347,12 +347,6 @@ func (c *StatusCommand) outputFailedPlacements(failedEval *api.Evaluation) {
|
|||
}
|
||||
}
|
||||
|
||||
// formatUnixNanoTime is a helper for formatting time for output.
|
||||
func (c *StatusCommand) formatUnixNanoTime(nano int64) string {
|
||||
t := time.Unix(0, nano)
|
||||
return formatTime(t)
|
||||
}
|
||||
|
||||
// convertApiJob is used to take a *api.Job and convert it to an *struct.Job.
|
||||
// This function is just a hammer and probably needs to be revisited.
|
||||
func convertApiJob(in *api.Job) (*structs.Job, error) {
|
||||
|
|
Loading…
Reference in New Issue