Limiting the alloc and eval ids based on short/verbose flags

This commit is contained in:
Diptanu Choudhury
2016-01-27 12:56:38 -08:00
parent 58d0529940
commit bd2cbfce8f
3 changed files with 21 additions and 6 deletions

View File

@@ -65,6 +65,11 @@ func (f *FSCatCommand) Run(args []string) int {
return 1
}
// Truncate the id unless full length is requested
length := shortId
if verbose {
length = fullId
}
// Query the allocation info
alloc, _, err := client.Allocations().Info(allocID, nil)
if err != nil {
@@ -93,8 +98,8 @@ func (f *FSCatCommand) Run(args []string) int {
out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status"
for i, alloc := range allocs {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s",
alloc.ID,
alloc.EvalID,
limit(alloc.ID, length),
limit(alloc.EvalID, length),
alloc.JobID,
alloc.TaskGroup,
alloc.DesiredStatus,

View File

@@ -64,6 +64,11 @@ func (f *FSListCommand) Run(args []string) int {
return 1
}
// Truncate the id unless full length is requested
length := shortId
if verbose {
length = fullId
}
// Query the allocation info
alloc, _, err := client.Allocations().Info(allocID, nil)
if err != nil {
@@ -92,8 +97,8 @@ func (f *FSListCommand) Run(args []string) int {
out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status"
for i, alloc := range allocs {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s",
alloc.ID,
alloc.EvalID,
limit(alloc.ID, length),
limit(alloc.EvalID, length),
alloc.JobID,
alloc.TaskGroup,
alloc.DesiredStatus,

View File

@@ -63,6 +63,11 @@ func (f *FSStatCommand) Run(args []string) int {
return 1
}
// Truncate the id unless full length is requested
length := shortId
if verbose {
length = fullId
}
// Query the allocation info
alloc, _, err := client.Allocations().Info(allocID, nil)
if err != nil {
@@ -91,8 +96,8 @@ func (f *FSStatCommand) Run(args []string) int {
out[0] = "ID|Eval ID|Job ID|Task Group|Desired Status|Client Status"
for i, alloc := range allocs {
out[i+1] = fmt.Sprintf("%s|%s|%s|%s|%s|%s",
alloc.ID,
alloc.EvalID,
limit(alloc.ID, length),
limit(alloc.EvalID, length),
alloc.JobID,
alloc.TaskGroup,
alloc.DesiredStatus,