mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
commit
98ae4f3b0c
1 changed files with 11 additions and 1 deletions
|
|
@ -367,6 +367,16 @@ func (c *Container) Attach() (*exec.Cmd, error) {
|
||||||
|
|
||||||
// Top returns process information
|
// Top returns process information
|
||||||
func (c *Container) Top() (container.ContainerTopOKBody, error) {
|
func (c *Container) Top() (container.ContainerTopOKBody, error) {
|
||||||
|
detail, err := c.Inspect()
|
||||||
|
if err != nil {
|
||||||
|
return container.ContainerTopOKBody{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// check container status
|
||||||
|
if !detail.State.Running {
|
||||||
|
return container.ContainerTopOKBody{}, errors.New("container is not running")
|
||||||
|
}
|
||||||
|
|
||||||
return c.Client.ContainerTop(context.Background(), c.ID, []string{})
|
return c.Client.ContainerTop(context.Background(), c.ID, []string{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,7 +421,7 @@ func (c *Container) Inspect() (types.ContainerJSON, error) {
|
||||||
|
|
||||||
// RenderTop returns details about the container
|
// RenderTop returns details about the container
|
||||||
func (c *Container) RenderTop() (string, error) {
|
func (c *Container) RenderTop() (string, error) {
|
||||||
result, err := c.Client.ContainerTop(context.Background(), c.ID, []string{})
|
result, err := c.Top()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue