Unverified Commit 25bb1b85 authored by Isabel Suchanek's avatar Isabel Suchanek
Browse files

Check for noop/no target rollback

parent e380c8f9
Branches unavailable
No related merge requests found
Showing with 21 additions and 9 deletions
+21 -9
......@@ -435,6 +435,10 @@ func (c *DeploymentStatusCommand) ttyMonitor(client *api.Client, deployID string
WaitTime: 2 * time.Second,
}
var statusComponent *glint.LayoutComponent
var endSpinner *glint.LayoutComponent
UPDATE:
for {
deploy, meta, err := client.Deployments().Info(deployID, &q)
if err != nil {
......@@ -447,7 +451,6 @@ func (c *DeploymentStatusCommand) ttyMonitor(client *api.Client, deployID string
}
status := deploy.Status
var statusComponent *glint.LayoutComponent
statusComponent = glint.Layout(
glint.Text(""),
glint.Text(formatTime(time.Now())),
......@@ -488,7 +491,7 @@ func (c *DeploymentStatusCommand) ttyMonitor(client *api.Client, deployID string
statusComponent = glint.Layout(statusComponent).MarginLeft(4)
d.Set(spinner, statusComponent)
endSpinner := glint.Layout(
endSpinner = glint.Layout(
components.Spinner(),
glint.Text(fmt.Sprintf(" Deployment %q %s", limit(deployID, length), status)),
).Row().MarginLeft(2)
......@@ -503,8 +506,6 @@ func (c *DeploymentStatusCommand) ttyMonitor(client *api.Client, deployID string
glint.Layout(glint.Text("")),
)
// Check no stable version to rollback to
// Check rollback != current deployID
// Wait for rollback to launch
time.Sleep(1 * time.Second)
rollback, _, err := client.Jobs().LatestDeployment(deploy.JobID, nil)
......@@ -518,25 +519,36 @@ func (c *DeploymentStatusCommand) ttyMonitor(client *api.Client, deployID string
return
}
// Check for noop/no target rollbacks
if rollback.ID == deploy.ID {
break UPDATE
}
d.Close()
c.ttyMonitor(client, rollback.ID, index, verbose)
} else {
// Render one final time with completion message
d.Set(endSpinner, statusComponent)
d.RenderFrame()
// d.Set(endSpinner, statusComponent)
// d.RenderFrame()
break UPDATE
}
return
case structs.DeploymentStatusSuccessful, structs.DeploymentStatusCancelled, structs.DeploymentStatusDescriptionBlocked:
// Render one final time with completion message
d.Set(endSpinner, statusComponent)
d.RenderFrame()
return
// d.Set(endSpinner, statusComponent)
// d.RenderFrame()
// return
break UPDATE
default:
q.WaitIndex = meta.LastIndex
continue
}
}
d.Set(endSpinner, statusComponent)
d.RenderFrame()
// return
}
// Used for Windows and non-tty
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment