mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Convert ContainerTopOKResponse from swagger spec.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
8d5f558de0
commit
16bdbaaa33
10 changed files with 47 additions and 32 deletions
|
@ -53,7 +53,7 @@ type monitorBackend interface {
|
|||
ContainerInspect(name string, size bool, version string) (interface{}, error)
|
||||
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
|
||||
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
|
||||
ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
|
||||
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
|
||||
|
||||
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
|
||||
}
|
||||
|
|
|
@ -3384,12 +3384,14 @@ paths:
|
|||
get:
|
||||
summary: "Get container stats based on resource usage"
|
||||
description: |
|
||||
This endpoint returns a live stream of a container’s resource usage statistics.
|
||||
This endpoint returns a live stream of a container’s resource usage
|
||||
statistics.
|
||||
|
||||
The `precpu_stats` is the CPU statistic of last read, which is used for calculating the CPU usage percentage. It is not the same as the `cpu_stats` field.
|
||||
The `precpu_stats` is the CPU statistic of last read, which is used
|
||||
for calculating the CPU usage percentage. It is not the same as the
|
||||
`cpu_stats` field.
|
||||
operationId: "ContainerStats"
|
||||
produces:
|
||||
- "application/json"
|
||||
produces: ["application/json"]
|
||||
responses:
|
||||
200:
|
||||
description: "no error"
|
||||
|
@ -4111,7 +4113,7 @@ paths:
|
|||
head:
|
||||
summary: "Get information about files in a container"
|
||||
description: "A response header `X-Docker-Container-Path-Stat` is return containing a base64 - encoded JSON object with some filesystem header information about the path."
|
||||
operationId: "ContainerArchiveHead"
|
||||
operationId: "ContainerArchiveInfo"
|
||||
responses:
|
||||
200:
|
||||
description: "no error"
|
||||
|
@ -4156,9 +4158,8 @@ paths:
|
|||
get:
|
||||
summary: "Get an archive of a filesystem resource in a container"
|
||||
description: "Get a tar archive of a resource in the filesystem of container id."
|
||||
operationId: "ContainerGetArchive"
|
||||
produces:
|
||||
- "application/x-tar"
|
||||
operationId: "ContainerArchive"
|
||||
produces: ["application/x-tar"]
|
||||
responses:
|
||||
200:
|
||||
description: "no error"
|
||||
|
@ -4199,10 +4200,8 @@ paths:
|
|||
put:
|
||||
summary: "Extract an archive of files or folders to a directory in a container"
|
||||
description: "Upload a tar archive to be extracted to a path in the filesystem of container id."
|
||||
operationId: "ContainerPutArchive"
|
||||
consumes:
|
||||
- "application/x-tar"
|
||||
- "application/octet-stream"
|
||||
operationId: "PutContainerArchive"
|
||||
consumes: ["application/x-tar", "application/octet-stream"]
|
||||
responses:
|
||||
200:
|
||||
description: "The content was extracted successfully"
|
||||
|
|
21
api/types/container/container_top.go
Normal file
21
api/types/container/container_top.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package container
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/swagger-gen.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ContainerTopOKBody container top o k body
|
||||
// swagger:model ContainerTopOKBody
|
||||
type ContainerTopOKBody struct {
|
||||
|
||||
// Each process running in the container, where each is process is an array of values corresponding to the titles
|
||||
// Required: true
|
||||
Processes [][]string `json:"Processes"`
|
||||
|
||||
// The ps column titles
|
||||
// Required: true
|
||||
Titles []string `json:"Titles"`
|
||||
}
|
|
@ -93,12 +93,6 @@ type ContainerStats struct {
|
|||
OSType string `json:"ostype"`
|
||||
}
|
||||
|
||||
// ContainerProcessList contains response of Engine API:
|
||||
// GET "/containers/{name:.*}/top"
|
||||
type ContainerProcessList struct {
|
||||
Processes [][]string
|
||||
Titles []string
|
||||
}
|
||||
|
||||
// Ping contains response of Engine API:
|
||||
// GET "/_ping"
|
||||
|
|
|
@ -5,13 +5,13 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// ContainerTop shows process information from within a container.
|
||||
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) {
|
||||
var response types.ContainerProcessList
|
||||
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) {
|
||||
var response container.ContainerTopOKBody
|
||||
query := url.Values{}
|
||||
if len(arguments) > 0 {
|
||||
query.Set("ps_args", strings.Join(arguments, " "))
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -43,7 +43,7 @@ func TestContainerTop(t *testing.T) {
|
|||
return nil, fmt.Errorf("args not set in URL query properly. Expected 'arg1 arg2', got %v", args)
|
||||
}
|
||||
|
||||
b, err := json.Marshal(types.ContainerProcessList{
|
||||
b, err := json.Marshal(container.ContainerTopOKBody{
|
||||
Processes: [][]string{
|
||||
{"p1", "p2"},
|
||||
{"p3"},
|
||||
|
|
|
@ -59,7 +59,7 @@ type ContainerAPIClient interface {
|
|||
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
||||
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
|
||||
ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
|
||||
ContainerTop(ctx context.Context, container string, arguments []string) (types.ContainerProcessList, error)
|
||||
ContainerTop(ctx context.Context, container string, arguments []string) (container.ContainerTopOKBody, error)
|
||||
ContainerUnpause(ctx context.Context, container string) error
|
||||
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
|
||||
ContainerWait(ctx context.Context, container string) (int64, error)
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
func validatePSArgs(psArgs string) error {
|
||||
|
@ -41,8 +41,8 @@ func fieldsASCII(s string) []string {
|
|||
return strings.FieldsFunc(s, fn)
|
||||
}
|
||||
|
||||
func parsePSOutput(output []byte, pids []int) (*types.ContainerProcessList, error) {
|
||||
procList := &types.ContainerProcessList{}
|
||||
func parsePSOutput(output []byte, pids []int) (*container.ContainerTopOKBody, error) {
|
||||
procList := &container.ContainerTopOKBody{}
|
||||
|
||||
lines := strings.Split(string(output), "\n")
|
||||
procList.Titles = fieldsASCII(lines[0])
|
||||
|
@ -86,7 +86,7 @@ func parsePSOutput(output []byte, pids []int) (*types.ContainerProcessList, erro
|
|||
// "-ef" if no args are given. An error is returned if the container
|
||||
// is not found, or is not running, or if there are any problems
|
||||
// running ps, or parsing the output.
|
||||
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) {
|
||||
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error) {
|
||||
if psArgs == "" {
|
||||
psArgs = "-ef"
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-units"
|
||||
)
|
||||
|
||||
|
@ -23,7 +23,7 @@ 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) (*types.ContainerProcessList, error) {
|
||||
func (daemon *Daemon) ContainerTop(name string, psArgs string) (*containertypes.ContainerTopOKBody, 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")
|
||||
|
@ -38,7 +38,7 @@ func (daemon *Daemon) ContainerTop(name string, psArgs string) (*types.Container
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
procList := &types.ContainerProcessList{}
|
||||
procList := &containertypes.ContainerTopOKBody{}
|
||||
procList.Titles = []string{"Name", "PID", "CPU", "Private Working Set"}
|
||||
|
||||
for _, j := range s {
|
||||
|
|
|
@ -19,6 +19,7 @@ swagger generate operation -f api/swagger.yaml \
|
|||
-n Authenticate \
|
||||
-n ContainerChanges \
|
||||
-n ContainerCreate \
|
||||
-n ContainerTop \
|
||||
-n ContainerUpdate \
|
||||
-n ContainerWait \
|
||||
-n ImageHistory \
|
||||
|
|
Loading…
Reference in a new issue