mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
change stop to be start stop
This commit is contained in:
parent
80af149b02
commit
001ad0de2d
4 changed files with 25 additions and 3 deletions
|
|
@ -59,6 +59,12 @@ func (c *Container) Remove(options dockerTypes.ContainerRemoveOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start starts the container
|
||||||
|
func (c *Container) Start() error {
|
||||||
|
c.Log.Warn(fmt.Sprintf("starting container %s", c.Name))
|
||||||
|
return c.Client.ContainerStart(context.Background(), c.ID, dockerTypes.ContainerStartOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
// Stop stops the container
|
// Stop stops the container
|
||||||
func (c *Container) Stop() error {
|
func (c *Container) Stop() error {
|
||||||
c.Log.Warn(fmt.Sprintf("stopping container %s", c.Name))
|
c.Log.Warn(fmt.Sprintf("stopping container %s", c.Name))
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,8 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: do same thing for start
|
||||||
|
// Fix UI not showing it being paused (it should say unpaused)
|
||||||
func (gui *Gui) PauseContainer(container *commands.Container) error {
|
func (gui *Gui) PauseContainer(container *commands.Container) error {
|
||||||
return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() (err error) {
|
return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() (err error) {
|
||||||
if container.Details.State.Paused {
|
if container.Details.State.Paused {
|
||||||
|
|
@ -367,12 +369,22 @@ func (gui *Gui) handleContainerPause(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.PauseContainer(container)
|
return gui.PauseContainer(container)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleContainerStop(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleContainerStartStop(g *gocui.Gui, v *gocui.View) error {
|
||||||
container, err := gui.Panels.Containers.GetSelectedItem()
|
container, err := gui.Panels.Containers.GetSelectedItem()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !(container.Container.State == "exited" || container.Container.State == "running") {
|
||||||
|
return gui.createErrorPanel(gui.Tr.CannotStartStop)
|
||||||
|
}
|
||||||
|
|
||||||
|
if container.Container.State == "exited" {
|
||||||
|
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error {
|
||||||
|
return container.Start()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return gui.createConfirmationPanel(gui.Tr.Confirm, gui.Tr.StopContainer, func(g *gocui.Gui, v *gocui.View) error {
|
return gui.createConfirmationPanel(gui.Tr.Confirm, gui.Tr.StopContainer, func(g *gocui.Gui, v *gocui.View) error {
|
||||||
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error {
|
return gui.WithWaitingStatus(gui.Tr.StoppingStatus, func() error {
|
||||||
if err := container.Stop(); err != nil {
|
if err := container.Stop(); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -210,8 +210,8 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
||||||
ViewName: "containers",
|
ViewName: "containers",
|
||||||
Key: 's',
|
Key: 's',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.handleContainerStop,
|
Handler: gui.handleContainerStartStop,
|
||||||
Description: gui.Tr.Stop,
|
Description: gui.Tr.StartStop,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "containers",
|
ViewName: "containers",
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ type TranslationSet struct {
|
||||||
CannotAttachStoppedContainerError string
|
CannotAttachStoppedContainerError string
|
||||||
CannotAccessDockerSocketError string
|
CannotAccessDockerSocketError string
|
||||||
CannotKillChildError string
|
CannotKillChildError string
|
||||||
|
CannotStartStop string
|
||||||
|
|
||||||
Donate string
|
Donate string
|
||||||
Cancel string
|
Cancel string
|
||||||
|
|
@ -59,6 +60,7 @@ type TranslationSet struct {
|
||||||
Down string
|
Down string
|
||||||
DownWithVolumes string
|
DownWithVolumes string
|
||||||
Start string
|
Start string
|
||||||
|
StartStop string
|
||||||
Rebuild string
|
Rebuild string
|
||||||
Recreate string
|
Recreate string
|
||||||
PreviousContext string
|
PreviousContext string
|
||||||
|
|
@ -153,6 +155,7 @@ func englishSet() TranslationSet {
|
||||||
CannotAttachStoppedContainerError: "You cannot attach to a stopped container, you need to start it first (which you can actually do with the 'r' key) (yes I'm too lazy to do this automatically for you) (pretty cool that I get to communicate one-on-one with you in the form of an error message though)",
|
CannotAttachStoppedContainerError: "You cannot attach to a stopped container, you need to start it first (which you can actually do with the 'r' key) (yes I'm too lazy to do this automatically for you) (pretty cool that I get to communicate one-on-one with you in the form of an error message though)",
|
||||||
CannotAccessDockerSocketError: "Can't access docker socket at: unix:///var/run/docker.sock\nRun lazydocker as root or read https://docs.docker.com/install/linux/linux-postinstall/",
|
CannotAccessDockerSocketError: "Can't access docker socket at: unix:///var/run/docker.sock\nRun lazydocker as root or read https://docs.docker.com/install/linux/linux-postinstall/",
|
||||||
CannotKillChildError: "Waited three seconds for child process to stop. There may be an orphan process that continues to run on your system.",
|
CannotKillChildError: "Waited three seconds for child process to stop. There may be an orphan process that continues to run on your system.",
|
||||||
|
CannotStartStop: "Cannot start stop this container",
|
||||||
|
|
||||||
Donate: "Donate",
|
Donate: "Donate",
|
||||||
Confirm: "Confirm",
|
Confirm: "Confirm",
|
||||||
|
|
@ -182,6 +185,7 @@ func englishSet() TranslationSet {
|
||||||
Down: "down project",
|
Down: "down project",
|
||||||
DownWithVolumes: "down project with volumes",
|
DownWithVolumes: "down project with volumes",
|
||||||
Start: "start",
|
Start: "start",
|
||||||
|
StartStop: "start/stop",
|
||||||
Rebuild: "rebuild",
|
Rebuild: "rebuild",
|
||||||
Recreate: "recreate",
|
Recreate: "recreate",
|
||||||
PreviousContext: "previous tab",
|
PreviousContext: "previous tab",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue