mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
really bad way to allow multiple containers per service
Signed-off-by: Dowideit, Sven (O&A, St. Lucia) <Sven.Dowideit@csiro.au>
This commit is contained in:
parent
3f593b75dc
commit
2f28baa52d
4 changed files with 21 additions and 21 deletions
|
|
@ -238,20 +238,19 @@ func (c *DockerCommand) RefreshContainersAndServices() error {
|
|||
}
|
||||
|
||||
func (c *DockerCommand) assignContainersToServices(containers []*Container, services []*Service) {
|
||||
L:
|
||||
for _, service := range services {
|
||||
for _, container := range containers {
|
||||
if !container.OneOff && container.ServiceName == service.Name {
|
||||
service.Container = container
|
||||
continue L
|
||||
service.Container = append(service.Container, container)
|
||||
continue
|
||||
}
|
||||
if container.Container.Labels["com.docker.swarm.service.name"] == service.Name {
|
||||
//Swarm service
|
||||
service.Container = container
|
||||
continue L
|
||||
service.Container = append(service.Container, container)
|
||||
container.ServiceName = service.Name
|
||||
continue
|
||||
}
|
||||
}
|
||||
service.Container = nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"os/exec"
|
||||
|
||||
"github.com/docker/docker/api/types/container"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/fatih/color"
|
||||
"github.com/jesseduffield/lazydocker/pkg/utils"
|
||||
|
|
@ -16,24 +17,24 @@ type Service struct {
|
|||
ID string
|
||||
OSCommand *OSCommand
|
||||
Log *logrus.Entry
|
||||
Container *Container
|
||||
Container []*Container
|
||||
DockerCommand LimitedDockerCommand
|
||||
}
|
||||
|
||||
// GetDisplayStrings returns the dispaly string of Container
|
||||
func (s *Service) GetDisplayStrings(isFocused bool) []string {
|
||||
|
||||
if s.Container == nil {
|
||||
if len(s.Container) == 0 {
|
||||
return []string{utils.ColoredString("none", color.FgBlue), s.Name, ""}
|
||||
}
|
||||
|
||||
cont := s.Container
|
||||
cont := s.Container[0]
|
||||
return []string{cont.GetDisplayStatus(), s.Name, cont.GetDisplayCPUPerc()}
|
||||
}
|
||||
|
||||
// Remove removes the service's containers
|
||||
func (s *Service) Remove(options types.ContainerRemoveOptions) error {
|
||||
return s.Container.Remove(options)
|
||||
return s.Container[0].Remove(options)
|
||||
}
|
||||
|
||||
// Stop stops the service's containers
|
||||
|
|
@ -58,12 +59,12 @@ func (s *Service) Restart() error {
|
|||
|
||||
// Attach attaches to the service
|
||||
func (s *Service) Attach() (*exec.Cmd, error) {
|
||||
return s.Container.Attach()
|
||||
return s.Container[0].Attach()
|
||||
}
|
||||
|
||||
// Top returns process information
|
||||
func (s *Service) Top() (container.ContainerTopOKBody, error) {
|
||||
return s.Container.Top()
|
||||
return s.Container[0].Top()
|
||||
}
|
||||
|
||||
// ViewLogs attaches to a subprocess viewing the service's logs
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func (gui *Gui) refreshProject() error {
|
|||
if gui.DockerCommand.InDockerComposeProject {
|
||||
for _, service := range gui.DockerCommand.Services {
|
||||
if service.Container != nil {
|
||||
projectName = service.Container.Details.Config.Labels["com.docker.compose.project"]
|
||||
projectName = service.Container[0].Details.Config.Labels["com.docker.compose.project"]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
containerID := ""
|
||||
if service.Container != nil {
|
||||
containerID = service.Container.ID
|
||||
containerID = service.Container[0].ID
|
||||
}
|
||||
|
||||
if err := gui.focusPoint(0, gui.State.Panels.Services.SelectedLine, len(gui.DockerCommand.Services), v); err != nil {
|
||||
|
|
@ -77,7 +77,7 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
|||
if service.Container == nil {
|
||||
return gui.renderString(gui.g, "main", gui.Tr.NoContainer)
|
||||
}
|
||||
if err := gui.renderContainerConfig(service.Container); err != nil {
|
||||
if err := gui.renderContainerConfig(service.Container[0]); err != nil {
|
||||
return err
|
||||
}
|
||||
case "top":
|
||||
|
|
@ -92,11 +92,11 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
|||
}
|
||||
|
||||
func (gui *Gui) renderServiceStats(service *commands.Service) error {
|
||||
if service.Container == nil {
|
||||
if len(service.Container) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.renderContainerStats(service.Container)
|
||||
return gui.renderContainerStats(service.Container[0])
|
||||
}
|
||||
|
||||
func (gui *Gui) renderServiceTop(service *commands.Service) error {
|
||||
|
|
@ -120,13 +120,13 @@ func (gui *Gui) renderServiceLogs(service *commands.Service) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
if service.Container == nil {
|
||||
if len(service.Container) == 0 {
|
||||
return gui.T.NewTask(func(stop chan struct{}) {
|
||||
gui.clearMainView()
|
||||
})
|
||||
}
|
||||
|
||||
return gui.renderContainerLogs(service.Container)
|
||||
return gui.renderContainerLogs(service.Container[0])
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServicesNextLine(g *gocui.Gui, v *gocui.View) error {
|
||||
|
|
@ -374,7 +374,7 @@ func (gui *Gui) handleServicesCustomCommand(g *gocui.Gui, v *gocui.View) error {
|
|||
|
||||
commandObject := gui.DockerCommand.NewCommandObject(commands.CommandObject{
|
||||
Service: service,
|
||||
Container: service.Container,
|
||||
Container: service.Container[0],
|
||||
})
|
||||
|
||||
var customCommands []config.CustomCommand
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue