deployment status in job status view

This commit is contained in:
Alex Dadgar
2017-07-06 22:44:05 -07:00
parent e5d8c0888f
commit 466702a2db
2 changed files with 32 additions and 2 deletions

View File

@@ -156,7 +156,11 @@ func formatDeployment(d *api.Deployment, uuidLength int) string {
return base
}
base += "\n\n[bold]Deployed[reset]\n"
base += formatDeploymentGroups(d, uuidLength)
return base
}
func formatDeploymentGroups(d *api.Deployment, uuidLength int) string {
// Detect if we need to add these columns
canaries, autorevert := false, false
for _, state := range d.TaskGroups {
@@ -197,6 +201,5 @@ func formatDeployment(d *api.Deployment, uuidLength int) string {
i++
}
base += formatList(rows)
return base
return formatList(rows)
}

View File

@@ -292,6 +292,11 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
return fmt.Errorf("Error querying job evaluations: %s", err)
}
latestDeployment, _, err := client.Jobs().LatestDeployment(*job.ID, nil)
if err != nil {
return fmt.Errorf("Error querying latest job deployment: %s", err)
}
// Output the summary
if err := c.outputJobSummary(client, job); err != nil {
return err
@@ -338,12 +343,34 @@ func (c *StatusCommand) outputJobInfo(client *api.Client, job *api.Job) error {
c.outputFailedPlacements(latestFailedPlacement)
}
if latestDeployment != nil && latestDeployment.Status != "successful" {
c.Ui.Output(c.Colorize().Color("\n[bold]Latest Deployment[reset]"))
c.Ui.Output(c.Colorize().Color(c.formatDeployment(latestDeployment)))
}
// Format the allocs
c.Ui.Output(c.Colorize().Color("\n[bold]Allocations[reset]"))
c.Ui.Output(formatAllocListStubs(jobAllocs, c.verbose, c.length))
return nil
}
func (c *StatusCommand) formatDeployment(d *api.Deployment) string {
// Format the high-level elements
high := []string{
fmt.Sprintf("ID|%s", limit(d.ID, c.length)),
fmt.Sprintf("Status|%s", d.Status),
fmt.Sprintf("Description|%s", d.StatusDescription),
}
base := formatKV(high)
if len(d.TaskGroups) == 0 {
return base
}
base += "\n\n[bold]Deployed[reset]\n"
base += formatDeploymentGroups(d, c.length)
return base
}
func formatAllocListStubs(stubs []*api.AllocationListStub, verbose bool, uuidLength int) string {
if len(stubs) == 0 {
return "No allocations placed"