mirror of https://github.com/docker/compose.git
Backend is responsible for generating containers IDs and truncate them if wanted/supported for docker ps
This commit is contained in:
parent
e604e7efc9
commit
f1a5f2d6cf
|
@ -6,7 +6,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
@ -58,7 +57,7 @@ func runPs(ctx context.Context, opts psOpts) error {
|
||||||
fmt.Fprintf(w, "CONTAINER ID\tIMAGE\tCOMMAND\tSTATUS\tPORTS\n")
|
fmt.Fprintf(w, "CONTAINER ID\tIMAGE\tCOMMAND\tSTATUS\tPORTS\n")
|
||||||
format := "%s\t%s\t%s\t%s\t%s\n"
|
format := "%s\t%s\t%s\t%s\t%s\n"
|
||||||
for _, c := range containers {
|
for _, c := range containers {
|
||||||
fmt.Fprintf(w, format, stringid.TruncateID(c.ID), c.Image, c.Command, c.Status, formatter.PortsString(c.Ports))
|
fmt.Fprintf(w, format, c.ID, c.Image, c.Command, c.Status, formatter.PortsString(c.Ports))
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.Flush()
|
return w.Flush()
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -61,7 +63,7 @@ func (ms *mobyService) List(ctx context.Context, all bool) ([]containers.Contain
|
||||||
var result []containers.Container
|
var result []containers.Container
|
||||||
for _, container := range css {
|
for _, container := range css {
|
||||||
result = append(result, containers.Container{
|
result = append(result, containers.Container{
|
||||||
ID: container.ID,
|
ID: stringid.TruncateID(container.ID),
|
||||||
Image: container.Image,
|
Image: container.Image,
|
||||||
// TODO: `Status` is a human readable string ("Up 24 minutes"),
|
// TODO: `Status` is a human readable string ("Up 24 minutes"),
|
||||||
// we need to return the `State` instead but first we need to
|
// we need to return the `State` instead but first we need to
|
||||||
|
|
|
@ -116,11 +116,15 @@ func (s *E2eACISuite) TestACIBackend() {
|
||||||
Expect(containerFields[1]).To(Equal("nginx"))
|
Expect(containerFields[1]).To(Equal("nginx"))
|
||||||
Expect(containerFields[2]).To(Equal("Running"))
|
Expect(containerFields[2]).To(Equal("Running"))
|
||||||
exposedIP := containerFields[3]
|
exposedIP := containerFields[3]
|
||||||
|
containerID := containerFields[0]
|
||||||
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
Expect(exposedIP).To(ContainSubstring(":80->80/tcp"))
|
||||||
|
|
||||||
publishedURL := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
publishedURL := strings.ReplaceAll(exposedIP, "->80/tcp", "")
|
||||||
output = s.NewCommand("curl", publishedURL).ExecOrDie()
|
output = s.NewCommand("curl", publishedURL).ExecOrDie()
|
||||||
Expect(output).To(ContainSubstring(testFileContent))
|
Expect(output).To(ContainSubstring(testFileContent))
|
||||||
|
|
||||||
|
output = s.NewDockerCommand("logs", containerID).ExecOrDie()
|
||||||
|
Expect(output).To(ContainSubstring("GET"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("removes container nginx", func() {
|
It("removes container nginx", func() {
|
||||||
|
|
Loading…
Reference in New Issue