diff --git a/command/deployment_status.go b/command/deployment_status.go index c38ba4b57..736bf5087 100644 --- a/command/deployment_status.go +++ b/command/deployment_status.go @@ -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) } diff --git a/command/status.go b/command/status.go index a970abc14..9a77f9110 100644 --- a/command/status.go +++ b/command/status.go @@ -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"