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)
|
ContainerInspect(name string, size bool, version string) (interface{}, error)
|
||||||
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
|
ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
|
||||||
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) 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)
|
Containers(config *types.ContainerListOptions) ([]*types.Container, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3384,12 +3384,14 @@ paths:
|
||||||
get:
|
get:
|
||||||
summary: "Get container stats based on resource usage"
|
summary: "Get container stats based on resource usage"
|
||||||
description: |
|
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"
|
operationId: "ContainerStats"
|
||||||
produces:
|
produces: ["application/json"]
|
||||||
- "application/json"
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "no error"
|
description: "no error"
|
||||||
|
@ -4111,7 +4113,7 @@ paths:
|
||||||
head:
|
head:
|
||||||
summary: "Get information about files in a container"
|
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."
|
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:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "no error"
|
description: "no error"
|
||||||
|
@ -4156,9 +4158,8 @@ paths:
|
||||||
get:
|
get:
|
||||||
summary: "Get an archive of a filesystem resource in a container"
|
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."
|
description: "Get a tar archive of a resource in the filesystem of container id."
|
||||||
operationId: "ContainerGetArchive"
|
operationId: "ContainerArchive"
|
||||||
produces:
|
produces: ["application/x-tar"]
|
||||||
- "application/x-tar"
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "no error"
|
description: "no error"
|
||||||
|
@ -4199,10 +4200,8 @@ paths:
|
||||||
put:
|
put:
|
||||||
summary: "Extract an archive of files or folders to a directory in a container"
|
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."
|
description: "Upload a tar archive to be extracted to a path in the filesystem of container id."
|
||||||
operationId: "ContainerPutArchive"
|
operationId: "PutContainerArchive"
|
||||||
consumes:
|
consumes: ["application/x-tar", "application/octet-stream"]
|
||||||
- "application/x-tar"
|
|
||||||
- "application/octet-stream"
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: "The content was extracted successfully"
|
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"`
|
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:
|
// Ping contains response of Engine API:
|
||||||
// GET "/_ping"
|
// GET "/_ping"
|
||||||
|
|
|
@ -5,13 +5,13 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerTop shows process information from within a container.
|
// ContainerTop shows process information from within a container.
|
||||||
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) {
|
func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (container.ContainerTopOKBody, error) {
|
||||||
var response types.ContainerProcessList
|
var response container.ContainerTopOKBody
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
if len(arguments) > 0 {
|
if len(arguments) > 0 {
|
||||||
query.Set("ps_args", strings.Join(arguments, " "))
|
query.Set("ps_args", strings.Join(arguments, " "))
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
"golang.org/x/net/context"
|
"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)
|
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{
|
Processes: [][]string{
|
||||||
{"p1", "p2"},
|
{"p1", "p2"},
|
||||||
{"p3"},
|
{"p3"},
|
||||||
|
|
|
@ -59,7 +59,7 @@ type ContainerAPIClient interface {
|
||||||
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
||||||
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
|
ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
|
||||||
ContainerStop(ctx context.Context, container string, timeout *time.Duration) 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
|
ContainerUnpause(ctx context.Context, container string) error
|
||||||
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
|
ContainerUpdate(ctx context.Context, container string, updateConfig container.UpdateConfig) (container.ContainerUpdateOKBody, error)
|
||||||
ContainerWait(ctx context.Context, container string) (int64, error)
|
ContainerWait(ctx context.Context, container string) (int64, error)
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/container"
|
||||||
)
|
)
|
||||||
|
|
||||||
func validatePSArgs(psArgs string) error {
|
func validatePSArgs(psArgs string) error {
|
||||||
|
@ -41,8 +41,8 @@ func fieldsASCII(s string) []string {
|
||||||
return strings.FieldsFunc(s, fn)
|
return strings.FieldsFunc(s, fn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parsePSOutput(output []byte, pids []int) (*types.ContainerProcessList, error) {
|
func parsePSOutput(output []byte, pids []int) (*container.ContainerTopOKBody, error) {
|
||||||
procList := &types.ContainerProcessList{}
|
procList := &container.ContainerTopOKBody{}
|
||||||
|
|
||||||
lines := strings.Split(string(output), "\n")
|
lines := strings.Split(string(output), "\n")
|
||||||
procList.Titles = fieldsASCII(lines[0])
|
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
|
// "-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
|
// is not found, or is not running, or if there are any problems
|
||||||
// running ps, or parsing the output.
|
// 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 == "" {
|
if psArgs == "" {
|
||||||
psArgs = "-ef"
|
psArgs = "-ef"
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
containertypes "github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import (
|
||||||
// task manager does and use the private working set as the memory counter.
|
// 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
|
// We could return more info for those who really understand how memory
|
||||||
// management works in Windows if we introduced a "raw" stats (above).
|
// 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
|
// It's not at all an equivalent to linux 'ps' on Windows
|
||||||
if psArgs != "" {
|
if psArgs != "" {
|
||||||
return nil, errors.New("Windows does not support arguments to top")
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
procList := &types.ContainerProcessList{}
|
procList := &containertypes.ContainerTopOKBody{}
|
||||||
procList.Titles = []string{"Name", "PID", "CPU", "Private Working Set"}
|
procList.Titles = []string{"Name", "PID", "CPU", "Private Working Set"}
|
||||||
|
|
||||||
for _, j := range s {
|
for _, j := range s {
|
||||||
|
|
|
@ -19,6 +19,7 @@ swagger generate operation -f api/swagger.yaml \
|
||||||
-n Authenticate \
|
-n Authenticate \
|
||||||
-n ContainerChanges \
|
-n ContainerChanges \
|
||||||
-n ContainerCreate \
|
-n ContainerCreate \
|
||||||
|
-n ContainerTop \
|
||||||
-n ContainerUpdate \
|
-n ContainerUpdate \
|
||||||
-n ContainerWait \
|
-n ContainerWait \
|
||||||
-n ImageHistory \
|
-n ImageHistory \
|
||||||
|
|
Loading…
Reference in a new issue