mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
allow upping and downing whole project
This commit is contained in:
parent
2f52bd04e6
commit
0cdac0bca3
5 changed files with 105 additions and 4 deletions
|
|
@ -42,8 +42,11 @@ logs:
|
|||
commandTemplates:
|
||||
dockerCompose: docker-compose
|
||||
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
||||
startService: '{{ .DockerCompose }} start {{ .Service.Name }}'
|
||||
up: '{{ .DockerCompose }} up -d'
|
||||
down: '{{ .DockerCompose }} down'
|
||||
downWithVolumes: '{{ .DockerCompose }} down --volumes'
|
||||
upService: '{{ .DockerCompose }} up -d {{ .Service.Name }}'
|
||||
startService: '{{ .DockerCompose }} start {{ .Service.Name }}'
|
||||
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
||||
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
||||
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
||||
|
|
|
|||
|
|
@ -141,6 +141,14 @@ type CommandTemplatesConfig struct {
|
|||
// UpService ups the service (creates and starts)
|
||||
UpService string `yaml:"upService,omitempty"`
|
||||
|
||||
// Runs "docker-compose up -d"
|
||||
Up string `yaml:"up,omitempty"`
|
||||
|
||||
// downs everything
|
||||
Down string `yaml:"down,omitempty"`
|
||||
// downs and removes volumes
|
||||
DownWithVolumes string `yaml:"downWithVolumes,omitempty"`
|
||||
|
||||
// DockerCompose is for your docker-compose command. You may want to combine a
|
||||
// few different docker-compose.yml files together, in which case you can set
|
||||
// this to "docker-compose -f foo/docker-compose.yml -f
|
||||
|
|
@ -351,6 +359,9 @@ func GetDefaultConfig() UserConfig {
|
|||
DockerCompose: "docker-compose",
|
||||
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
||||
StartService: "{{ .DockerCompose }} start {{ .Service.Name }}",
|
||||
Up: "{{ .DockerCompose }} up -d",
|
||||
Down: "{{ .DockerCompose }} down",
|
||||
DownWithVolumes: "{{ .DockerCompose }} down --volumes",
|
||||
UpService: "{{ .DockerCompose }} up -d {{ .Service.Name }}",
|
||||
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
||||
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
||||
|
|
|
|||
|
|
@ -339,6 +339,20 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleServiceRenderLogsToMain,
|
||||
Description: gui.Tr.ViewLogs,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'U',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleProjectUp,
|
||||
Description: gui.Tr.UpProject,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'D',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleProjectDown,
|
||||
Description: gui.Tr.DownProject,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: '[',
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ func (gui *Gui) handleServiceUp(g *gocui.Gui, v *gocui.View) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.UppingStatus, func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.UppingServiceStatus, func() error {
|
||||
if err := service.Up(); err != nil {
|
||||
return gui.createErrorPanel(err.Error())
|
||||
}
|
||||
|
|
@ -325,6 +325,67 @@ func (gui *Gui) handleServiceRenderLogsToMain(g *gocui.Gui, v *gocui.View) error
|
|||
return gui.runSubprocess(c)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleProjectUp(g *gocui.Gui, v *gocui.View) error {
|
||||
cmdStr := utils.ApplyTemplate(
|
||||
gui.Config.UserConfig.CommandTemplates.Up,
|
||||
gui.DockerCommand.NewCommandObject(commands.CommandObject{}),
|
||||
)
|
||||
|
||||
return gui.WithWaitingStatus(gui.Tr.UppingAllStatus, func() error {
|
||||
if err := gui.OSCommand.RunCommand(cmdStr); err != nil {
|
||||
return gui.createErrorPanel(err.Error())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleProjectDown(g *gocui.Gui, v *gocui.View) error {
|
||||
downCommand := utils.ApplyTemplate(
|
||||
gui.Config.UserConfig.CommandTemplates.Down,
|
||||
gui.DockerCommand.NewCommandObject(commands.CommandObject{}),
|
||||
)
|
||||
|
||||
downWithVolumesCommand := utils.ApplyTemplate(
|
||||
gui.Config.UserConfig.CommandTemplates.DownWithVolumes,
|
||||
gui.DockerCommand.NewCommandObject(commands.CommandObject{}),
|
||||
)
|
||||
|
||||
options := []*commandOption{
|
||||
{
|
||||
description: gui.Tr.Down,
|
||||
command: downCommand,
|
||||
f: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.DowningStatus, func() error {
|
||||
if err := gui.OSCommand.RunCommand(downCommand); err != nil {
|
||||
return gui.createErrorPanel(err.Error())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
description: gui.Tr.DownWithVolumes,
|
||||
command: downWithVolumesCommand,
|
||||
f: func() error {
|
||||
return gui.WithWaitingStatus(gui.Tr.DowningStatus, func() error {
|
||||
if err := gui.OSCommand.RunCommand(downWithVolumesCommand); err != nil {
|
||||
return gui.createErrorPanel(err.Error())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
description: gui.Tr.Cancel,
|
||||
f: func() error { return nil },
|
||||
},
|
||||
}
|
||||
|
||||
handleMenuPress := func(index int) error { return options[index].f() }
|
||||
|
||||
return gui.createMenu("", options, len(options), handleMenuPress)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServiceRestartMenu(g *gocui.Gui, v *gocui.View) error {
|
||||
service, err := gui.getSelectedService()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ type TranslationSet struct {
|
|||
RestartingStatus string
|
||||
StartingStatus string
|
||||
StoppingStatus string
|
||||
UppingStatus string
|
||||
UppingAllStatus string
|
||||
UppingServiceStatus string
|
||||
PausingStatus string
|
||||
RemovingStatus string
|
||||
DowningStatus string
|
||||
RunningCustomCommandStatus string
|
||||
RunningBulkCommandStatus string
|
||||
RemoveService string
|
||||
|
|
@ -51,6 +53,8 @@ type TranslationSet struct {
|
|||
Stop string
|
||||
Pause string
|
||||
Restart string
|
||||
Down string
|
||||
DownWithVolumes string
|
||||
Start string
|
||||
Rebuild string
|
||||
Recreate string
|
||||
|
|
@ -58,6 +62,8 @@ type TranslationSet struct {
|
|||
NextContext string
|
||||
Attach string
|
||||
ViewLogs string
|
||||
UpProject string
|
||||
DownProject string
|
||||
ServicesTitle string
|
||||
ContainersTitle string
|
||||
StandaloneContainersTitle string
|
||||
|
|
@ -118,7 +124,9 @@ func englishSet() TranslationSet {
|
|||
RestartingStatus: "restarting",
|
||||
StartingStatus: "starting",
|
||||
StoppingStatus: "stopping",
|
||||
UppingStatus: "upping",
|
||||
UppingServiceStatus: "upping service",
|
||||
UppingAllStatus: "upping all",
|
||||
DowningStatus: "downing",
|
||||
PausingStatus: "pausing",
|
||||
RunningCustomCommandStatus: "running custom command",
|
||||
RunningBulkCommandStatus: "running bulk command",
|
||||
|
|
@ -156,6 +164,8 @@ func englishSet() TranslationSet {
|
|||
Stop: "stop",
|
||||
Pause: "pause",
|
||||
Restart: "restart",
|
||||
Down: "down project",
|
||||
DownWithVolumes: "down project with volumes",
|
||||
Start: "start",
|
||||
Rebuild: "rebuild",
|
||||
Recreate: "recreate",
|
||||
|
|
@ -163,6 +173,8 @@ func englishSet() TranslationSet {
|
|||
NextContext: "next tab",
|
||||
Attach: "attach",
|
||||
ViewLogs: "view logs",
|
||||
UpProject: "up project",
|
||||
DownProject: "down project",
|
||||
RemoveImage: "remove image",
|
||||
RemoveVolume: "remove volume",
|
||||
RemoveWithoutPrune: "remove without deleting untagged parents",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue