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