Small fixes and UX changes

This commit is contained in:
Alex Dadgar
2017-07-19 13:34:24 -07:00
parent dedb9127a3
commit bdb71e7074
4 changed files with 19 additions and 18 deletions

View File

@@ -42,7 +42,7 @@ func (c *DeploymentFailCommand) Synopsis() string {
func (c *DeploymentFailCommand) Run(args []string) int {
var detach, verbose bool
flags := c.Meta.FlagSet("deployment resume", FlagSetClient)
flags := c.Meta.FlagSet("deployment fail", FlagSetClient)
flags.Usage = func() { c.Ui.Output(c.Help()) }
flags.BoolVar(&detach, "detach", false, "")
flags.BoolVar(&verbose, "verbose", false, "")

View File

@@ -30,12 +30,9 @@ General Options:
Promote Options:
-all
All promotes all task groups in the deployment.
-group
Group may be specified many times and is used to promote that particular
group.
group. If no specific groups are specified, all groups are promoted.
-detach
Return immediately instead of entering monitor mode. After deployment
@@ -49,16 +46,15 @@ Promote Options:
}
func (c *DeploymentPromoteCommand) Synopsis() string {
return "Manually fail a deployment"
return "Promote canaries in a deployment"
}
func (c *DeploymentPromoteCommand) Run(args []string) int {
var all, detach, verbose bool
var detach, verbose bool
var groups []string
flags := c.Meta.FlagSet("deployment resume", FlagSetClient)
flags := c.Meta.FlagSet("deployment promote", FlagSetClient)
flags.Usage = func() { c.Ui.Output(c.Help()) }
flags.BoolVar(&all, "all", false, "")
flags.BoolVar(&detach, "detach", false, "")
flags.BoolVar(&verbose, "verbose", false, "")
flags.Var((*flaghelper.StringFlag)(&groups), "group", "")
@@ -73,10 +69,6 @@ func (c *DeploymentPromoteCommand) Run(args []string) int {
c.Ui.Error(c.Help())
return 1
}
if !all && len(groups) == 0 {
c.Ui.Error("Either -all or one or more -group flags must be specified.")
return 1
}
dID := args[0]
// Truncate the id unless full length is requested
@@ -105,14 +97,14 @@ func (c *DeploymentPromoteCommand) Run(args []string) int {
}
var u *api.DeploymentUpdateResponse
if all {
if len(groups) == 0 {
u, _, err = client.Deployments().PromoteAll(deploy.ID, nil)
} else {
u, _, err = client.Deployments().PromoteGroups(deploy.ID, groups, nil)
}
if err != nil {
c.Ui.Error(fmt.Sprintf("Error failing deployment: %s", err))
c.Ui.Error(fmt.Sprintf("Error promoting deployment: %s", err))
return 1
}

View File

@@ -177,9 +177,12 @@ func formatDeploymentGroups(d *api.Deployment, uuidLength int) string {
if autorevert {
rowString += "Auto Revert|"
}
if canaries {
rowString += "Promoted|"
}
rowString += "Desired|"
if canaries {
rowString += "Canaries|Promoted|"
rowString += "Canaries|"
}
rowString += "Placed|Healthy|Unhealthy"
@@ -191,10 +194,12 @@ func formatDeploymentGroups(d *api.Deployment, uuidLength int) string {
if autorevert {
row += fmt.Sprintf("%v|", state.AutoRevert)
}
if canaries {
row += fmt.Sprintf("%v|", state.Promoted)
}
row += fmt.Sprintf("%d|", state.DesiredTotal)
if canaries {
row += fmt.Sprintf("%d|", state.DesiredCanaries)
row += fmt.Sprintf("%v|", state.Promoted)
}
row += fmt.Sprintf("%d|%d|%d", state.PlacedAllocs, state.HealthyAllocs, state.UnhealthyAllocs)
rows[i] = row

View File

@@ -122,7 +122,11 @@ func (d *Deployment) Pause(args *structs.DeploymentPauseRequest, reply *structs.
}
if !deploy.Active() {
return fmt.Errorf("can't pause terminal deployment")
if args.Pause {
return fmt.Errorf("can't pause terminal deployment")
}
return fmt.Errorf("can't resume terminal deployment")
}
// Call into the deployment watcher