mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
refactor
This commit is contained in:
parent
6c27cf3f32
commit
52fb944bfb
2 changed files with 6 additions and 15 deletions
|
|
@ -593,6 +593,11 @@ func (gui *Gui) handleContainersOpenInBrowserCommand(g *gocui.Gui, v *gocui.View
|
|||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.openContainerInBrowser(container)
|
||||
}
|
||||
|
||||
func (gui *Gui) openContainerInBrowser(container *commands.Container) error {
|
||||
// skip if no any ports
|
||||
if len(container.Container.Ports) == 0 {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -421,19 +421,5 @@ func (gui *Gui) handleServicesOpenInBrowserCommand(g *gocui.Gui, v *gocui.View)
|
|||
return gui.createErrorPanel(gui.g, gui.Tr.NoContainers)
|
||||
}
|
||||
|
||||
// skip if no any ports
|
||||
if len(container.Container.Ports) == 0 {
|
||||
return nil
|
||||
}
|
||||
// skip if the first port is not published
|
||||
port := container.Container.Ports[0]
|
||||
if port.IP == "" {
|
||||
return nil
|
||||
}
|
||||
ip := port.IP
|
||||
if ip == "0.0.0.0" {
|
||||
ip = "localhost"
|
||||
}
|
||||
link := fmt.Sprintf("http://%s:%d/", ip, port.PublicPort)
|
||||
return gui.OSCommand.OpenLink(link)
|
||||
return gui.openContainerInBrowser(container)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue