mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Open in browser
Most containers expose some http port. We can open it in browser. For simplicity we can just open first container's published port.
This commit is contained in:
parent
415b14fb10
commit
7ede2f8297
3 changed files with 32 additions and 0 deletions
|
|
@ -571,3 +571,26 @@ func (gui *Gui) handleContainersBulkCommand(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
|
||||||
return gui.createBulkCommandMenu(bulkCommands, commandObject)
|
return gui.createBulkCommandMenu(bulkCommands, commandObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open first port in browser
|
||||||
|
func (gui *Gui) handleContainersOpenInBrowserCommand(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
container, err := gui.getSelectedContainer()
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,6 +262,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleContainersBulkCommand,
|
Handler: gui.handleContainersBulkCommand,
|
||||||
Description: gui.Tr.ViewBulkCommands,
|
Description: gui.Tr.ViewBulkCommands,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "containers",
|
||||||
|
Key: 'w',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleContainersOpenInBrowserCommand,
|
||||||
|
Description: gui.Tr.OpenInBrowser,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "services",
|
ViewName: "services",
|
||||||
Key: 'd',
|
Key: 'd',
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ type TranslationSet struct {
|
||||||
ViewRestartOptions string
|
ViewRestartOptions string
|
||||||
RunCustomCommand string
|
RunCustomCommand string
|
||||||
ViewBulkCommands string
|
ViewBulkCommands string
|
||||||
|
OpenInBrowser string
|
||||||
|
|
||||||
LogsTitle string
|
LogsTitle string
|
||||||
ConfigTitle string
|
ConfigTitle string
|
||||||
|
|
@ -150,6 +151,7 @@ func englishSet() TranslationSet {
|
||||||
ViewRestartOptions: "view restart options",
|
ViewRestartOptions: "view restart options",
|
||||||
RunCustomCommand: "run predefined custom command",
|
RunCustomCommand: "run predefined custom command",
|
||||||
ViewBulkCommands: "view bulk commands",
|
ViewBulkCommands: "view bulk commands",
|
||||||
|
OpenInBrowser: "open in browser (first port is http)",
|
||||||
|
|
||||||
AnonymousReportingTitle: "Help make lazydocker better",
|
AnonymousReportingTitle: "Help make lazydocker better",
|
||||||
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker?",
|
AnonymousReportingPrompt: "Would you like to enable anonymous reporting data to help improve lazydocker?",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue