Sort the task resources in alloc-status

This commit is contained in:
Alex Dadgar 2016-04-07 14:55:48 -07:00
parent 967c1870a4
commit b6e1057974
1 changed files with 10 additions and 1 deletions

View File

@ -307,9 +307,18 @@ func (c *AllocStatusCommand) taskResources(alloc *api.Allocation) {
return
}
// Sort the tasks.
tasks := make([]string, 0, len(alloc.TaskResources))
for task := range alloc.TaskResources {
tasks = append(tasks, task)
}
sort.Strings(tasks)
c.Ui.Output("\n==> Task Resources")
firstLine := true
for task, resource := range alloc.TaskResources {
for _, task := range tasks {
resource := alloc.TaskResources[task]
header := fmt.Sprintf("\nTask: %q", task)
if firstLine {
header = fmt.Sprintf("Task: %q", task)