mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-24 16:11:04 +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)
|
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
|
// Restart restarts the container
|
||||||
func (c *Container) Restart() error {
|
func (c *Container) Restart() error {
|
||||||
c.Log.Warn(fmt.Sprintf("restarting container %s", c.Name))
|
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)
|
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 {
|
func (gui *Gui) handleContainerStop(g *gocui.Gui, v *gocui.View) error {
|
||||||
container, err := gui.getSelectedContainer()
|
container, err := gui.getSelectedContainer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleHideStoppedContainers,
|
Handler: gui.handleHideStoppedContainers,
|
||||||
Description: gui.Tr.HideStopped,
|
Description: gui.Tr.HideStopped,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "containers",
|
||||||
|
Key: 'p',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleContainerPause,
|
||||||
|
Description: gui.Tr.Pause,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "containers",
|
ViewName: "containers",
|
||||||
Key: 's',
|
Key: 's',
|
||||||
|
|
@ -290,6 +297,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
Handler: gui.handleServiceStop,
|
Handler: gui.handleServiceStop,
|
||||||
Description: gui.Tr.Stop,
|
Description: gui.Tr.Stop,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ViewName: "services",
|
||||||
|
Key: 'p',
|
||||||
|
Modifier: gocui.ModNone,
|
||||||
|
Handler: gui.handleServicePause,
|
||||||
|
Description: gui.Tr.Pause,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ViewName: "services",
|
ViewName: "services",
|
||||||
Key: 'r',
|
Key: 'r',
|
||||||
|
|
|
||||||
|
|
@ -219,6 +219,18 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.createServiceCommandMenu(options, gui.Tr.RemovingStatus)
|
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 {
|
func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
|
||||||
service, err := gui.getSelectedService()
|
service, err := gui.getSelectedService()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,13 @@ type TranslationSet struct {
|
||||||
RestartingStatus string
|
RestartingStatus string
|
||||||
StartingStatus string
|
StartingStatus string
|
||||||
StoppingStatus string
|
StoppingStatus string
|
||||||
|
PausingStatus string
|
||||||
RemovingStatus string
|
RemovingStatus string
|
||||||
RunningCustomCommandStatus string
|
RunningCustomCommandStatus string
|
||||||
RunningBulkCommandStatus string
|
RunningBulkCommandStatus string
|
||||||
RemoveService string
|
RemoveService string
|
||||||
Stop string
|
Stop string
|
||||||
|
Pause string
|
||||||
Restart string
|
Restart string
|
||||||
Start string
|
Start string
|
||||||
Rebuild string
|
Rebuild string
|
||||||
|
|
@ -112,6 +114,7 @@ func englishSet() TranslationSet {
|
||||||
RestartingStatus: "restarting",
|
RestartingStatus: "restarting",
|
||||||
StartingStatus: "starting",
|
StartingStatus: "starting",
|
||||||
StoppingStatus: "stopping",
|
StoppingStatus: "stopping",
|
||||||
|
PausingStatus: "pausing",
|
||||||
RunningCustomCommandStatus: "running custom command",
|
RunningCustomCommandStatus: "running custom command",
|
||||||
RunningBulkCommandStatus: "running bulk command",
|
RunningBulkCommandStatus: "running bulk command",
|
||||||
|
|
||||||
|
|
@ -146,6 +149,7 @@ func englishSet() TranslationSet {
|
||||||
RemoveWithVolumes: "remove with volumes",
|
RemoveWithVolumes: "remove with volumes",
|
||||||
RemoveService: "remove containers",
|
RemoveService: "remove containers",
|
||||||
Stop: "stop",
|
Stop: "stop",
|
||||||
|
Pause: "pause",
|
||||||
Restart: "restart",
|
Restart: "restart",
|
||||||
Start: "start",
|
Start: "start",
|
||||||
Rebuild: "rebuild",
|
Rebuild: "rebuild",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue