mirror of https://github.com/docker/compose.git
Fix: change append to use slice index in ps.go
Signed-off-by: Blane Tschida <btdothemath@gmail.com>
This commit is contained in:
parent
495a087fb5
commit
250c3112b9
|
@ -45,17 +45,17 @@ func (s *composeService) Ps(ctx context.Context, projectName string, options api
|
|||
for i, container := range containers {
|
||||
i, container := i, container
|
||||
eg.Go(func() error {
|
||||
var publishers []api.PortPublisher
|
||||
publishers := make([]api.PortPublisher, len(container.Ports))
|
||||
sort.Slice(container.Ports, func(i, j int) bool {
|
||||
return container.Ports[i].PrivatePort < container.Ports[j].PrivatePort
|
||||
})
|
||||
for _, p := range container.Ports {
|
||||
publishers = append(publishers, api.PortPublisher{
|
||||
for i, p := range container.Ports {
|
||||
publishers[i] = api.PortPublisher{
|
||||
URL: p.IP,
|
||||
TargetPort: int(p.PrivatePort),
|
||||
PublishedPort: int(p.PublicPort),
|
||||
Protocol: p.Type,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
inspect, err := s.apiClient().ContainerInspect(ctx, container.ID)
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestPs(t *testing.T) {
|
|||
|
||||
expected := []compose.ContainerSummary{
|
||||
{ID: "123", Name: "123", Names: []string{"/123"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service1",
|
||||
State: "running", Health: "healthy", Publishers: nil,
|
||||
State: "running", Health: "healthy", Publishers: []compose.PortPublisher{},
|
||||
Labels: map[string]string{
|
||||
compose.ProjectLabel: strings.ToLower(testProject),
|
||||
compose.ConfigFilesLabel: "/src/pkg/compose/testdata/compose.yaml",
|
||||
|
@ -75,7 +75,7 @@ func TestPs(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{ID: "789", Name: "789", Names: []string{"/789"}, Image: "foo", Project: strings.ToLower(testProject), Service: "service2",
|
||||
State: "exited", Health: "", ExitCode: 130, Publishers: nil,
|
||||
State: "exited", Health: "", ExitCode: 130, Publishers: []compose.PortPublisher{},
|
||||
Labels: map[string]string{
|
||||
compose.ProjectLabel: strings.ToLower(testProject),
|
||||
compose.ConfigFilesLabel: "/src/pkg/compose/testdata/compose.yaml",
|
||||
|
|
Loading…
Reference in New Issue