api/types/container: rename ContainerTopOKBody to TopResponse

Deprecate ContainerTopOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-02-10 18:49:07 +01:00
parent f4dc38cd36
commit be1ac5d8e5
11 changed files with 99 additions and 92 deletions

View File

@@ -6,7 +6,7 @@ import (
"fmt"
"time"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/container"
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
"github.com/docker/go-units"
)
@@ -26,27 +26,27 @@ import (
// task manager does and use the private working set as the memory counter.
// We could return more info for those who really understand how memory
// management works in Windows if we introduced a "raw" stats (above).
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.ContainerTopOKBody, error) {
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*container.TopResponse, error) {
// It's not at all an equivalent to linux 'ps' on Windows
if psArgs != "" {
return nil, errors.New("Windows does not support arguments to top")
}
container, err := daemon.GetContainer(name)
ctr, err := daemon.GetContainer(name)
if err != nil {
return nil, err
}
task, err := func() (libcontainerdtypes.Task, error) {
container.Lock()
defer container.Unlock()
ctr.Lock()
defer ctr.Unlock()
task, err := container.GetRunningTask()
task, err := ctr.GetRunningTask()
if err != nil {
return nil, err
}
if container.Restarting {
return nil, errContainerIsRestarting(container.ID)
if ctr.Restarting {
return nil, errContainerIsRestarting(ctr.ID)
}
return task, nil
}()
@@ -55,8 +55,9 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.
if err != nil {
return nil, err
}
procList := &containertypes.ContainerTopOKBody{}
procList.Titles = []string{"Name", "PID", "CPU", "Private Working Set"}
procList := &container.TopResponse{
Titles: []string{"Name", "PID", "CPU", "Private Working Set"},
}
for _, j := range s {
d := time.Duration((j.KernelTime_100Ns + j.UserTime_100Ns) * 100) // Combined time in nanoseconds