From b6e1057974e4e0dd2fb7d9e1e6773381b397b42e Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Thu, 7 Apr 2016 14:55:48 -0700 Subject: [PATCH] Sort the task resources in alloc-status --- command/alloc_status.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/command/alloc_status.go b/command/alloc_status.go index 7e0e97bb2..700a17546 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -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)