fixup: from review feedback

Fix a logic error in ECS scale-down button, bad copy/paste in
ActiveControls() and neaten the switch cases in container controls.

Co-Authored-By: Filip Barl <filip@weave.works>
This commit is contained in:
Bryan Boreham
2020-01-13 09:04:55 +00:00
committed by Bryan Boreham
parent 635cea0b56
commit 1dcdfab05a
3 changed files with 4 additions and 5 deletions

View File

@@ -153,7 +153,7 @@ func (r Reporter) Tag(rpt report.Report) (report.Report, error) {
activeControls := []string{ScaleUp}
// Disable ScaleDown when only 1 task is desired, since
// scaling down to 0 would cause the service to disappear (#2085)
if service.DesiredCount < 1 {
if service.DesiredCount > 1 {
activeControls = append(activeControls, ScaleDown)
}
rpt.ECSService.AddNode(report.MakeNodeWith(serviceID, map[string]string{

View File

@@ -391,13 +391,12 @@ func (c *container) getBaseNode() report.Node {
// Return a slice including all controls that should be shown on this container
func (c *container) controls() []string {
paused := c.container.State.Paused
switch {
case paused:
case c.container.State.Paused:
return []string{UnpauseContainer}
case c.container.State.Running:
return []string{RestartContainer, StopContainer, PauseContainer, AttachContainer, ExecContainer}
case !c.container.State.Running:
default:
return []string{StartContainer, RemoveContainer}
}
return nil

View File

@@ -124,7 +124,7 @@ func (n Node) WithLatestActiveControls(cs ...string) Node {
}
// ActiveControls returns a string slice with the names of active controls.
func (n Node) ActiveControls(cs ...string) []string {
func (n Node) ActiveControls() []string {
activeControls, _ := n.Latest.Lookup(NodeActiveControls)
return strings.Split(activeControls, ScopeDelim)
}