mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
Merge pull request #376 from jesseduffield/up-services
This commit is contained in:
commit
26b40a9d94
11 changed files with 44 additions and 14 deletions
|
|
@ -43,6 +43,7 @@ commandTemplates:
|
|||
dockerCompose: docker-compose
|
||||
restartService: '{{ .DockerCompose }} restart {{ .Service.Name }}'
|
||||
startService: '{{ .DockerCompose }} start {{ .Service.Name }}'
|
||||
upService: '{{ .DockerCompose }} up -d {{ .Service.Name }}'
|
||||
stopService: '{{ .DockerCompose }} stop {{ .Service.Name }}'
|
||||
serviceLogs: '{{ .DockerCompose }} logs --since=60m --follow {{ .Service.Name }}'
|
||||
viewServiceLogs: '{{ .DockerCompose }} logs --follow {{ .Service.Name }}'
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||
## Dienste
|
||||
|
||||
<pre>
|
||||
<kbd>u</kbd>: up service
|
||||
<kbd>d</kbd>: entferne Container
|
||||
<kbd>s</kbd>: anhalten
|
||||
<kbd>p</kbd>: pause
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||
## Services
|
||||
|
||||
<pre>
|
||||
<kbd>u</kbd>: up service
|
||||
<kbd>d</kbd>: remove containers
|
||||
<kbd>s</kbd>: stop
|
||||
<kbd>p</kbd>: pause
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||
## Diensten
|
||||
|
||||
<pre>
|
||||
<kbd>u</kbd>: up service
|
||||
<kbd>d</kbd>: verwijder containers
|
||||
<kbd>s</kbd>: stop
|
||||
<kbd>p</kbd>: pause
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||
## Serwisy
|
||||
|
||||
<pre>
|
||||
<kbd>u</kbd>: up service
|
||||
<kbd>d</kbd>: usuń kontenery
|
||||
<kbd>s</kbd>: zatrzymaj
|
||||
<kbd>p</kbd>: pause
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
|||
## Servisler
|
||||
|
||||
<pre>
|
||||
<kbd>u</kbd>: up service
|
||||
<kbd>d</kbd>: konteynerleri kaldır
|
||||
<kbd>s</kbd>: durdur
|
||||
<kbd>p</kbd>: pause
|
||||
|
|
|
|||
|
|
@ -38,29 +38,27 @@ func (s *Service) Remove(options types.ContainerRemoveOptions) error {
|
|||
|
||||
// Stop stops the service's containers
|
||||
func (s *Service) Stop() error {
|
||||
templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StopService
|
||||
command := utils.ApplyTemplate(
|
||||
templateString,
|
||||
s.DockerCommand.NewCommandObject(CommandObject{Service: s}),
|
||||
)
|
||||
return s.OSCommand.RunCommand(command)
|
||||
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.StopService)
|
||||
}
|
||||
|
||||
// Up up's the service
|
||||
func (s *Service) Up() error {
|
||||
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.UpService)
|
||||
}
|
||||
|
||||
// Restart restarts the service
|
||||
func (s *Service) Restart() error {
|
||||
templateString := s.OSCommand.Config.UserConfig.CommandTemplates.RestartService
|
||||
command := utils.ApplyTemplate(
|
||||
templateString,
|
||||
s.DockerCommand.NewCommandObject(CommandObject{Service: s}),
|
||||
)
|
||||
return s.OSCommand.RunCommand(command)
|
||||
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.RestartService)
|
||||
}
|
||||
|
||||
// Restart starts the service
|
||||
func (s *Service) Start() error {
|
||||
templateString := s.OSCommand.Config.UserConfig.CommandTemplates.StartService
|
||||
return s.runCommand(s.OSCommand.Config.UserConfig.CommandTemplates.StartService)
|
||||
}
|
||||
|
||||
func (s *Service) runCommand(templateCmdStr string) error {
|
||||
command := utils.ApplyTemplate(
|
||||
templateString,
|
||||
templateCmdStr,
|
||||
s.DockerCommand.NewCommandObject(CommandObject{Service: s}),
|
||||
)
|
||||
return s.OSCommand.RunCommand(command)
|
||||
|
|
|
|||
|
|
@ -138,6 +138,9 @@ type CommandTemplatesConfig struct {
|
|||
// StartService is just like the above but for starting
|
||||
StartService string `yaml:"startService,omitempty"`
|
||||
|
||||
// UpService ups the service (creates and starts)
|
||||
UpService string `yaml:"upService,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
|
||||
|
|
@ -348,6 +351,7 @@ func GetDefaultConfig() UserConfig {
|
|||
DockerCompose: "docker-compose",
|
||||
RestartService: "{{ .DockerCompose }} restart {{ .Service.Name }}",
|
||||
StartService: "{{ .DockerCompose }} start {{ .Service.Name }}",
|
||||
UpService: "{{ .DockerCompose }} up -d {{ .Service.Name }}",
|
||||
RebuildService: "{{ .DockerCompose }} up -d --build {{ .Service.Name }}",
|
||||
RecreateService: "{{ .DockerCompose }} up -d --force-recreate {{ .Service.Name }}",
|
||||
StopService: "{{ .DockerCompose }} stop {{ .Service.Name }}",
|
||||
|
|
|
|||
|
|
@ -283,6 +283,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleContainersOpenInBrowserCommand,
|
||||
Description: gui.Tr.OpenInBrowser,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'u',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServiceUp,
|
||||
Description: gui.Tr.UpService,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'd',
|
||||
|
|
|
|||
|
|
@ -248,6 +248,19 @@ func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
|
|||
}, nil)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServiceUp(g *gocui.Gui, v *gocui.View) error {
|
||||
service, err := gui.getSelectedService()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := service.Up(); err != nil {
|
||||
return gui.createErrorPanel(err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServiceRestart(g *gocui.Gui, v *gocui.View) error {
|
||||
service, err := gui.getSelectedService()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ type TranslationSet struct {
|
|||
RunningCustomCommandStatus string
|
||||
RunningBulkCommandStatus string
|
||||
RemoveService string
|
||||
UpService string
|
||||
Stop string
|
||||
Pause string
|
||||
Restart string
|
||||
|
|
@ -149,6 +150,7 @@ func englishSet() TranslationSet {
|
|||
ForceRemove: "force remove",
|
||||
RemoveWithVolumes: "remove with volumes",
|
||||
RemoveService: "remove containers",
|
||||
UpService: "up service",
|
||||
Stop: "stop",
|
||||
Pause: "pause",
|
||||
Restart: "restart",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue