mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
deployment status in job status view
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user