mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
support viewing docker compose config from status panel
This commit is contained in:
parent
d81c407dd2
commit
84090bcb94
4 changed files with 47 additions and 42 deletions
|
|
@ -401,3 +401,12 @@ func (c *DockerCommand) ViewAllLogs() (*exec.Cmd, error) {
|
||||||
|
|
||||||
return cmd, nil
|
return cmd, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DockerComposeConfig returns the result of 'docker-compose config'
|
||||||
|
func (c *DockerCommand) DockerComposeConfig() string {
|
||||||
|
output, err := c.OSCommand.RunCommandWithOutput(c.OSCommand.Config.UserConfig.CommandTemplates.DockerComposeConfig)
|
||||||
|
if err != nil {
|
||||||
|
output = err.Error()
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -110,11 +110,12 @@ type CommandTemplatesConfig struct {
|
||||||
RebuildService string `yaml:"rebuildService,omitempty"`
|
RebuildService string `yaml:"rebuildService,omitempty"`
|
||||||
|
|
||||||
// ViewContainerLogs is for viewing the container logs in a subprocess. We have this as a separate command in case you want to show all the logs rather than just tail them for the sake of reducing CPU load when in the lazydocker GUI
|
// ViewContainerLogs is for viewing the container logs in a subprocess. We have this as a separate command in case you want to show all the logs rather than just tail them for the sake of reducing CPU load when in the lazydocker GUI
|
||||||
ViewContainerLogs string `yaml:"viewContainerLogs,omitempty"`
|
ViewContainerLogs string `yaml:"viewContainerLogs,omitempty"`
|
||||||
ContainerLogs string `yaml:"containerLogs,omitempty"`
|
ContainerLogs string `yaml:"containerLogs,omitempty"`
|
||||||
ContainerTTYLogs string `yaml:"containerTTYLogs,omitempty"`
|
ContainerTTYLogs string `yaml:"containerTTYLogs,omitempty"`
|
||||||
AllLogs string `yaml:"allLogs,omitempty"`
|
AllLogs string `yaml:"allLogs,omitempty"`
|
||||||
ViewAllLogs string `yaml:"viewAlLogs,omitempty"`
|
ViewAllLogs string `yaml:"viewAlLogs,omitempty"`
|
||||||
|
DockerComposeConfig string `yaml:"dockerComposeConfig,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type OSConfig struct {
|
type OSConfig struct {
|
||||||
|
|
@ -162,16 +163,17 @@ func GetDefaultConfig() UserConfig {
|
||||||
Reporting: "undetermined",
|
Reporting: "undetermined",
|
||||||
ConfirmOnQuit: false,
|
ConfirmOnQuit: false,
|
||||||
CommandTemplates: CommandTemplatesConfig{
|
CommandTemplates: CommandTemplatesConfig{
|
||||||
RestartService: "docker-compose restart {{ .Name }}",
|
RestartService: "docker-compose restart {{ .Name }}",
|
||||||
RebuildService: "docker-compose up -d --build {{ .Name }}",
|
RebuildService: "docker-compose up -d --build {{ .Name }}",
|
||||||
DockerCompose: "apdev compose",
|
DockerCompose: "apdev compose",
|
||||||
StopService: "apdev stop {{ .Name }}",
|
StopService: "apdev stop {{ .Name }}",
|
||||||
ServiceLogs: "apdev logs {{ .Name }}",
|
ServiceLogs: "apdev logs {{ .Name }}",
|
||||||
ContainerLogs: "docker logs --timestamps --follow --tail=100 {{ .ID }}",
|
ContainerLogs: "docker logs --timestamps --follow --tail=100 {{ .ID }}",
|
||||||
ViewContainerLogs: "docker logs --timestamps --follow --tail=100 {{ .ID }}",
|
ViewContainerLogs: "docker logs --timestamps --follow --tail=100 {{ .ID }}",
|
||||||
ContainerTTYLogs: "docker logs --follow --tail=100 {{ .ID }}",
|
ContainerTTYLogs: "docker logs --follow --tail=100 {{ .ID }}",
|
||||||
AllLogs: "apdev logs --tail=100",
|
AllLogs: "apdev logs --tail=100",
|
||||||
ViewAllLogs: "apdev logs",
|
ViewAllLogs: "apdev logs",
|
||||||
|
DockerComposeConfig: "apdev compose config",
|
||||||
},
|
},
|
||||||
OS: GetPlatformDefaultConfig(),
|
OS: GetPlatformDefaultConfig(),
|
||||||
Update: UpdateConfig{
|
Update: UpdateConfig{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
|
|
@ -14,11 +13,11 @@ import (
|
||||||
// list panel functions
|
// list panel functions
|
||||||
|
|
||||||
func (gui *Gui) getServiceContexts() []string {
|
func (gui *Gui) getServiceContexts() []string {
|
||||||
return []string{"logs", "stats", "config", "container-config"}
|
return []string{"logs", "stats", "container-config"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getServiceContextTitles() []string {
|
func (gui *Gui) getServiceContextTitles() []string {
|
||||||
return []string{gui.Tr.LogsTitle, gui.Tr.StatsTitle, gui.Tr.ConfigTitle, gui.Tr.ContainerConfigTitle}
|
return []string{gui.Tr.LogsTitle, gui.Tr.StatsTitle, gui.Tr.ContainerConfigTitle}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getSelectedService() (*commands.Service, error) {
|
func (gui *Gui) getSelectedService() (*commands.Service, error) {
|
||||||
|
|
@ -85,10 +84,6 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
if err := gui.renderServiceLogs(service); err != nil {
|
if err := gui.renderServiceLogs(service); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case "config":
|
|
||||||
if err := gui.renderServiceConfig(service); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
case "stats":
|
case "stats":
|
||||||
if err := gui.renderServiceStats(service); err != nil {
|
if err := gui.renderServiceStats(service); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -107,24 +102,6 @@ func (gui *Gui) handleServiceSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderServiceConfig(service *commands.Service) error {
|
|
||||||
mainView := gui.getMainView()
|
|
||||||
mainView.Autoscroll = false
|
|
||||||
mainView.Wrap = true
|
|
||||||
|
|
||||||
go gui.T.NewTask(func(stop chan struct{}) {
|
|
||||||
// TODO: actually show service config
|
|
||||||
data, err := json.MarshalIndent(&service.Container.Container, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
gui.Log.Error(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gui.renderString(gui.g, "main", string(data))
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) renderServiceStats(service *commands.Service) error {
|
func (gui *Gui) renderServiceStats(service *commands.Service) error {
|
||||||
if service.Container == nil {
|
if service.Container == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) getStatusContexts() []string {
|
func (gui *Gui) getStatusContexts() []string {
|
||||||
return []string{"logs", "credits"}
|
return []string{"logs", "credits", "config"}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getStatusContextTitles() []string {
|
func (gui *Gui) getStatusContextTitles() []string {
|
||||||
return []string{gui.Tr.LogsTitle, gui.Tr.CreditsTitle}
|
return []string{gui.Tr.LogsTitle, gui.Tr.CreditsTitle, gui.Tr.ConfigTitle}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) refreshStatus() error {
|
func (gui *Gui) refreshStatus() error {
|
||||||
|
|
@ -59,6 +59,10 @@ func (gui *Gui) handleStatusSelect(g *gocui.Gui, v *gocui.View) error {
|
||||||
if err := gui.renderAllLogs(); err != nil {
|
if err := gui.renderAllLogs(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
case "config":
|
||||||
|
if err := gui.renderDockerComposeConfig(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return errors.New("Unknown context for status panel")
|
return errors.New("Unknown context for status panel")
|
||||||
}
|
}
|
||||||
|
|
@ -116,6 +120,19 @@ func (gui *Gui) renderAllLogs() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) renderDockerComposeConfig() error {
|
||||||
|
mainView := gui.getMainView()
|
||||||
|
mainView.Autoscroll = false
|
||||||
|
mainView.Wrap = true
|
||||||
|
|
||||||
|
go gui.T.NewTask(func(stop chan struct{}) {
|
||||||
|
config := gui.DockerCommand.DockerComposeConfig()
|
||||||
|
gui.renderString(gui.g, "main", config)
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleOpenConfig(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleOpenConfig(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.openFile(gui.Config.ConfigFilename())
|
return gui.openFile(gui.Config.ConfigFilename())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue