Merge pull request #1251 from gtardif/compose_health_display

Remove the HEALTH column in `docker compose ps`
This commit is contained in:
Guillaume Tardif 2021-02-05 17:55:04 +01:00 committed by GitHub
commit a5b148bda1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -93,8 +93,12 @@ func runPs(ctx context.Context, opts psOptions) error {
ports = append(ports, fmt.Sprintf("%s->%d/%s", p.URL, p.TargetPort, p.Protocol))
}
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", container.Name, container.Service, container.State, container.Health, strings.Join(ports, ", "))
status := container.State
if container.Health != "" {
status = fmt.Sprintf("%s (%s)", container.State, container.Health)
}
_, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", container.Name, container.Service, status, strings.Join(ports, ", "))
}
},
"NAME", "SERVICE", "STATE", "HEALTH", "PORTS")
"NAME", "SERVICE", "STATUS", "PORTS")
}

View File

@ -89,10 +89,15 @@ func TestLocalComposeUp(t *testing.T) {
})
t.Run("check healthcheck display", func(t *testing.T) {
t.Run("check healthcheck output", func(t *testing.T) {
c.WaitForCmdResult(c.NewDockerCmd("compose", "-p", projectName, "ps", "--format", "json"),
StdoutContains(`"Name":"compose-e2e-demo_web_1","Project":"compose-e2e-demo","Service":"web","State":"running","Health":"healthy"`),
5*time.Second, 1*time.Second)
res := c.RunDockerCmd("compose", "-p", projectName, "ps")
res.Assert(t, icmd.Expected{Out: `NAME SERVICE STATUS PORTS`})
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_web_1 web running (healthy) 0.0.0.0:90->80/tcp`})
res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_db_1 db running 5432/tcp`})
})
t.Run("down", func(t *testing.T) {

View File

@ -13,4 +13,4 @@ services:
- "my-label=test"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:80/"]
interval: 5s
interval: 2s