mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-22 07:11:01 +00:00
Merge pull request #317 from mark2185/feature/docker-pause
This commit is contained in:
commit
3abff083ad
5 changed files with 67 additions and 0 deletions
|
|
@ -175,6 +175,18 @@ func (c *Container) Stop() error {
|
|||
return c.Client.ContainerStop(context.Background(), c.ID, nil)
|
||||
}
|
||||
|
||||
// Pause pauses the container
|
||||
func (c *Container) Pause() error {
|
||||
c.Log.Warn(fmt.Sprintf("pausing container %s", c.Name))
|
||||
return c.Client.ContainerPause(context.Background(), c.ID)
|
||||
}
|
||||
|
||||
// Unpause unpauses the container
|
||||
func (c *Container) Unpause() error {
|
||||
c.Log.Warn(fmt.Sprintf("unpausing container %s", c.Name))
|
||||
return c.Client.ContainerUnpause(context.Background(), c.ID)
|
||||
}
|
||||
|
||||
// Restart restarts the container
|
||||
func (c *Container) Restart() error {
|
||||
c.Log.Warn(fmt.Sprintf("restarting container %s", c.Name))
|
||||
|
|
|
|||
|
|
@ -423,6 +423,31 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
return gui.createMenu("", options, len(options), handleMenuPress)
|
||||
}
|
||||
|
||||
func (gui *Gui) PauseContainer(container *commands.Container) error {
|
||||
return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() (err error) {
|
||||
if container.Details.State.Paused {
|
||||
err = container.Unpause()
|
||||
} else {
|
||||
err = container.Pause()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return gui.createErrorPanel(gui.g, err.Error())
|
||||
}
|
||||
|
||||
return gui.refreshContainersAndServices()
|
||||
})
|
||||
}
|
||||
|
||||
func (gui *Gui) handleContainerPause(g *gocui.Gui, v *gocui.View) error {
|
||||
container, err := gui.getSelectedContainer()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.PauseContainer(container)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleContainerStop(g *gocui.Gui, v *gocui.View) error {
|
||||
container, err := gui.getSelectedContainer()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -220,6 +220,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleHideStoppedContainers,
|
||||
Description: gui.Tr.HideStopped,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 'p',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleContainerPause,
|
||||
Description: gui.Tr.Pause,
|
||||
},
|
||||
{
|
||||
ViewName: "containers",
|
||||
Key: 's',
|
||||
|
|
@ -290,6 +297,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||
Handler: gui.handleServiceStop,
|
||||
Description: gui.Tr.Stop,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'p',
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: gui.handleServicePause,
|
||||
Description: gui.Tr.Pause,
|
||||
},
|
||||
{
|
||||
ViewName: "services",
|
||||
Key: 'r',
|
||||
|
|
|
|||
|
|
@ -219,6 +219,18 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
|||
return gui.createServiceCommandMenu(options, gui.Tr.RemovingStatus)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServicePause(g *gocui.Gui, v *gocui.View) error {
|
||||
service, err := gui.getSelectedService()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if service.Container == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.PauseContainer(service.Container)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
|
||||
service, err := gui.getSelectedService()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -42,11 +42,13 @@ type TranslationSet struct {
|
|||
RestartingStatus string
|
||||
StartingStatus string
|
||||
StoppingStatus string
|
||||
PausingStatus string
|
||||
RemovingStatus string
|
||||
RunningCustomCommandStatus string
|
||||
RunningBulkCommandStatus string
|
||||
RemoveService string
|
||||
Stop string
|
||||
Pause string
|
||||
Restart string
|
||||
Start string
|
||||
Rebuild string
|
||||
|
|
@ -112,6 +114,7 @@ func englishSet() TranslationSet {
|
|||
RestartingStatus: "restarting",
|
||||
StartingStatus: "starting",
|
||||
StoppingStatus: "stopping",
|
||||
PausingStatus: "pausing",
|
||||
RunningCustomCommandStatus: "running custom command",
|
||||
RunningBulkCommandStatus: "running bulk command",
|
||||
|
||||
|
|
@ -146,6 +149,7 @@ func englishSet() TranslationSet {
|
|||
RemoveWithVolumes: "remove with volumes",
|
||||
RemoveService: "remove containers",
|
||||
Stop: "stop",
|
||||
Pause: "pause",
|
||||
Restart: "restart",
|
||||
Start: "start",
|
||||
Rebuild: "rebuild",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue