mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31: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 {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return gui.openContainerInBrowser(container)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) openContainerInBrowser(container *commands.Container) error {
|
||||||
// skip if no any ports
|
// skip if no any ports
|
||||||
if len(container.Container.Ports) == 0 {
|
if len(container.Container.Ports) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -421,19 +421,5 @@ func (gui *Gui) handleServicesOpenInBrowserCommand(g *gocui.Gui, v *gocui.View)
|
||||||
return gui.createErrorPanel(gui.g, gui.Tr.NoContainers)
|
return gui.createErrorPanel(gui.g, gui.Tr.NoContainers)
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip if no any ports
|
return gui.openContainerInBrowser(container)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue