mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #14897 from WeiZhang555/golint-api-types
fix golint warnings/errors on package api/types/
This commit is contained in:
commit
0a0e9701f7
16 changed files with 104 additions and 68 deletions
|
@ -61,8 +61,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", info.DockerRootDir)
|
fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", info.DockerRootDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HttpProxy)
|
ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy)
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HttpsProxy)
|
ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HTTPSProxy)
|
||||||
ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy)
|
ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy)
|
||||||
|
|
||||||
if info.IndexServerAddress != "" {
|
if info.IndexServerAddress != "" {
|
||||||
|
@ -87,7 +87,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
|
||||||
if !info.BridgeNfIptables {
|
if !info.BridgeNfIptables {
|
||||||
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-iptables is disabled\n")
|
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-iptables is disabled\n")
|
||||||
}
|
}
|
||||||
if !info.BridgeNfIp6tables {
|
if !info.BridgeNfIP6tables {
|
||||||
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled\n")
|
fmt.Fprintf(cli.err, "WARNING: bridge-nf-call-ip6tables is disabled\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ func (s *containerStats) Collect(cli *DockerCli, streamStats bool) {
|
||||||
memPercent = float64(v.MemoryStats.Usage) / float64(v.MemoryStats.Limit) * 100.0
|
memPercent = float64(v.MemoryStats.Usage) / float64(v.MemoryStats.Limit) * 100.0
|
||||||
cpuPercent = 0.0
|
cpuPercent = 0.0
|
||||||
)
|
)
|
||||||
previousCPU = v.PreCpuStats.CpuUsage.TotalUsage
|
previousCPU = v.PreCPUStats.CPUUsage.TotalUsage
|
||||||
previousSystem = v.PreCpuStats.SystemUsage
|
previousSystem = v.PreCPUStats.SystemUsage
|
||||||
cpuPercent = calculateCPUPercent(previousCPU, previousSystem, v)
|
cpuPercent = calculateCPUPercent(previousCPU, previousSystem, v)
|
||||||
blkRead, blkWrite := calculateBlockIO(v.BlkioStats)
|
blkRead, blkWrite := calculateBlockIO(v.BlkioStats)
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
@ -196,13 +196,13 @@ func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.Stats) flo
|
||||||
var (
|
var (
|
||||||
cpuPercent = 0.0
|
cpuPercent = 0.0
|
||||||
// calculate the change for the cpu usage of the container in between readings
|
// calculate the change for the cpu usage of the container in between readings
|
||||||
cpuDelta = float64(v.CpuStats.CpuUsage.TotalUsage - previousCPU)
|
cpuDelta = float64(v.CPUStats.CPUUsage.TotalUsage - previousCPU)
|
||||||
// calculate the change for the entire system between readings
|
// calculate the change for the entire system between readings
|
||||||
systemDelta = float64(v.CpuStats.SystemUsage - previousSystem)
|
systemDelta = float64(v.CPUStats.SystemUsage - previousSystem)
|
||||||
)
|
)
|
||||||
|
|
||||||
if systemDelta > 0.0 && cpuDelta > 0.0 {
|
if systemDelta > 0.0 && cpuDelta > 0.0 {
|
||||||
cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) * 100.0
|
cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CPUStats.CPUUsage.PercpuUsage)) * 100.0
|
||||||
}
|
}
|
||||||
return cpuPercent
|
return cpuPercent
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
|
|
||||||
var versionTemplate = `Client:
|
var versionTemplate = `Client:
|
||||||
Version: {{.Client.Version}}
|
Version: {{.Client.Version}}
|
||||||
API version: {{.Client.ApiVersion}}
|
API version: {{.Client.APIVersion}}
|
||||||
Go version: {{.Client.GoVersion}}
|
Go version: {{.Client.GoVersion}}
|
||||||
Git commit: {{.Client.GitCommit}}
|
Git commit: {{.Client.GitCommit}}
|
||||||
Built: {{.Client.BuildTime}}
|
Built: {{.Client.BuildTime}}
|
||||||
|
@ -24,7 +24,7 @@ var versionTemplate = `Client:
|
||||||
|
|
||||||
Server:
|
Server:
|
||||||
Version: {{.Server.Version}}
|
Version: {{.Server.Version}}
|
||||||
API version: {{.Server.ApiVersion}}
|
API version: {{.Server.APIVersion}}
|
||||||
Go version: {{.Server.GoVersion}}
|
Go version: {{.Server.GoVersion}}
|
||||||
Git commit: {{.Server.GitCommit}}
|
Git commit: {{.Server.GitCommit}}
|
||||||
Built: {{.Server.BuildTime}}
|
Built: {{.Server.BuildTime}}
|
||||||
|
@ -61,7 +61,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
|
||||||
vd := versionData{
|
vd := versionData{
|
||||||
Client: types.Version{
|
Client: types.Version{
|
||||||
Version: dockerversion.VERSION,
|
Version: dockerversion.VERSION,
|
||||||
ApiVersion: api.Version,
|
APIVersion: api.Version,
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
GitCommit: dockerversion.GITCOMMIT,
|
GitCommit: dockerversion.GITCOMMIT,
|
||||||
BuildTime: dockerversion.BUILDTIME,
|
BuildTime: dockerversion.BUILDTIME,
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
func (s *Server) getVersion(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (s *Server) getVersion(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
v := &types.Version{
|
v := &types.Version{
|
||||||
Version: dockerversion.VERSION,
|
Version: dockerversion.VERSION,
|
||||||
ApiVersion: api.Version,
|
APIVersion: api.Version,
|
||||||
GitCommit: dockerversion.GITCOMMIT,
|
GitCommit: dockerversion.GITCOMMIT,
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
Os: runtime.GOOS,
|
Os: runtime.GOOS,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// This package is used for API stability in the types and response to the
|
// Package types is used for API stability in the types and response to the
|
||||||
// consumers of the API stats endpoint.
|
// consumers of the API stats endpoint.
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
// ThrottlingData stores CPU throttling stats of one running container
|
||||||
type ThrottlingData struct {
|
type ThrottlingData struct {
|
||||||
// Number of periods with throttling active
|
// Number of periods with throttling active
|
||||||
Periods uint64 `json:"periods"`
|
Periods uint64 `json:"periods"`
|
||||||
|
@ -13,8 +14,8 @@ type ThrottlingData struct {
|
||||||
ThrottledTime uint64 `json:"throttled_time"`
|
ThrottledTime uint64 `json:"throttled_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// All CPU stats are aggregated since container inception.
|
// CPUUsage stores All CPU stats aggregated since container inception.
|
||||||
type CpuUsage struct {
|
type CPUUsage struct {
|
||||||
// Total CPU time consumed.
|
// Total CPU time consumed.
|
||||||
// Units: nanoseconds.
|
// Units: nanoseconds.
|
||||||
TotalUsage uint64 `json:"total_usage"`
|
TotalUsage uint64 `json:"total_usage"`
|
||||||
|
@ -29,12 +30,14 @@ type CpuUsage struct {
|
||||||
UsageInUsermode uint64 `json:"usage_in_usermode"`
|
UsageInUsermode uint64 `json:"usage_in_usermode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CpuStats struct {
|
// CPUStats aggregates and wraps all CPU related info of container
|
||||||
CpuUsage CpuUsage `json:"cpu_usage"`
|
type CPUStats struct {
|
||||||
|
CPUUsage CPUUsage `json:"cpu_usage"`
|
||||||
SystemUsage uint64 `json:"system_cpu_usage"`
|
SystemUsage uint64 `json:"system_cpu_usage"`
|
||||||
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
|
ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemoryStats aggregates All memory stats since container inception
|
||||||
type MemoryStats struct {
|
type MemoryStats struct {
|
||||||
// current res_counter usage for memory
|
// current res_counter usage for memory
|
||||||
Usage uint64 `json:"usage"`
|
Usage uint64 `json:"usage"`
|
||||||
|
@ -48,6 +51,7 @@ type MemoryStats struct {
|
||||||
Limit uint64 `json:"limit"`
|
Limit uint64 `json:"limit"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlkioStatEntry is one small entity to store a piece of Blkio stats
|
||||||
// TODO Windows: This can be factored out
|
// TODO Windows: This can be factored out
|
||||||
type BlkioStatEntry struct {
|
type BlkioStatEntry struct {
|
||||||
Major uint64 `json:"major"`
|
Major uint64 `json:"major"`
|
||||||
|
@ -56,6 +60,7 @@ type BlkioStatEntry struct {
|
||||||
Value uint64 `json:"value"`
|
Value uint64 `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BlkioStats stores All IO service stats for data read and write
|
||||||
// TODO Windows: This can be factored out
|
// TODO Windows: This can be factored out
|
||||||
type BlkioStats struct {
|
type BlkioStats struct {
|
||||||
// number of bytes tranferred to and from the block device
|
// number of bytes tranferred to and from the block device
|
||||||
|
@ -69,8 +74,9 @@ type BlkioStats struct {
|
||||||
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"`
|
SectorsRecursive []BlkioStatEntry `json:"sectors_recursive"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NetworkStats aggregates All network stats of one container
|
||||||
// TODO Windows: This will require refactoring
|
// TODO Windows: This will require refactoring
|
||||||
type Network struct {
|
type NetworkStats struct {
|
||||||
RxBytes uint64 `json:"rx_bytes"`
|
RxBytes uint64 `json:"rx_bytes"`
|
||||||
RxPackets uint64 `json:"rx_packets"`
|
RxPackets uint64 `json:"rx_packets"`
|
||||||
RxErrors uint64 `json:"rx_errors"`
|
RxErrors uint64 `json:"rx_errors"`
|
||||||
|
@ -81,11 +87,12 @@ type Network struct {
|
||||||
TxDropped uint64 `json:"tx_dropped"`
|
TxDropped uint64 `json:"tx_dropped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stats is Ultimate struct aggregating all types of stats of one container
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
Read time.Time `json:"read"`
|
Read time.Time `json:"read"`
|
||||||
Network Network `json:"network,omitempty"`
|
Network NetworkStats `json:"network,omitempty"`
|
||||||
PreCpuStats CpuStats `json:"precpu_stats,omitempty"`
|
PreCPUStats CPUStats `json:"precpu_stats,omitempty"`
|
||||||
CpuStats CpuStats `json:"cpu_stats,omitempty"`
|
CPUStats CPUStats `json:"cpu_stats,omitempty"`
|
||||||
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
|
||||||
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
BlkioStats BlkioStats `json:"blkio_stats,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,35 +19,41 @@ type ContainerCreateResponse struct {
|
||||||
Warnings []string `json:"Warnings"`
|
Warnings []string `json:"Warnings"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /containers/{name:.*}/exec
|
// ContainerExecCreateResponse contains response of Remote API:
|
||||||
|
// POST "/containers/{name:.*}/exec"
|
||||||
type ContainerExecCreateResponse struct {
|
type ContainerExecCreateResponse struct {
|
||||||
// ID is the exec ID.
|
// ID is the exec ID.
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST /auth
|
// AuthResponse contains response of Remote API:
|
||||||
|
// POST "/auth"
|
||||||
type AuthResponse struct {
|
type AuthResponse struct {
|
||||||
// Status is the authentication status
|
// Status is the authentication status
|
||||||
Status string `json:"Status"`
|
Status string `json:"Status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerWaitResponse contains response of Remote API:
|
||||||
// POST "/containers/"+containerID+"/wait"
|
// POST "/containers/"+containerID+"/wait"
|
||||||
type ContainerWaitResponse struct {
|
type ContainerWaitResponse struct {
|
||||||
// StatusCode is the status code of the wait job
|
// StatusCode is the status code of the wait job
|
||||||
StatusCode int `json:"StatusCode"`
|
StatusCode int `json:"StatusCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerCommitResponse contains response of Remote API:
|
||||||
// POST "/commit?container="+containerID
|
// POST "/commit?container="+containerID
|
||||||
type ContainerCommitResponse struct {
|
type ContainerCommitResponse struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerChange contains response of Remote API:
|
||||||
// GET "/containers/{name:.*}/changes"
|
// GET "/containers/{name:.*}/changes"
|
||||||
type ContainerChange struct {
|
type ContainerChange struct {
|
||||||
Kind int
|
Kind int
|
||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageHistory contains response of Remote API:
|
||||||
// GET "/images/{name:.*}/history"
|
// GET "/images/{name:.*}/history"
|
||||||
type ImageHistory struct {
|
type ImageHistory struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
|
@ -58,16 +64,18 @@ type ImageHistory struct {
|
||||||
Comment string
|
Comment string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageDelete contains response of Remote API:
|
||||||
// DELETE "/images/{name:.*}"
|
// DELETE "/images/{name:.*}"
|
||||||
type ImageDelete struct {
|
type ImageDelete struct {
|
||||||
Untagged string `json:",omitempty"`
|
Untagged string `json:",omitempty"`
|
||||||
Deleted string `json:",omitempty"`
|
Deleted string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Image contains response of Remote API:
|
||||||
// GET "/images/json"
|
// GET "/images/json"
|
||||||
type Image struct {
|
type Image struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
ParentId string
|
ParentID string `json:"ParentId"`
|
||||||
RepoTags []string
|
RepoTags []string
|
||||||
RepoDigests []string
|
RepoDigests []string
|
||||||
Created int64
|
Created int64
|
||||||
|
@ -76,14 +84,17 @@ type Image struct {
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GraphDriverData returns Image's graph driver config info
|
||||||
|
// when calling inspect command
|
||||||
type GraphDriverData struct {
|
type GraphDriverData struct {
|
||||||
Name string
|
Name string
|
||||||
Data map[string]string
|
Data map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ImageInspect contains response of Remote API:
|
||||||
// GET "/images/{name:.*}/json"
|
// GET "/images/{name:.*}/json"
|
||||||
type ImageInspect struct {
|
type ImageInspect struct {
|
||||||
Id string
|
ID string `json:"Id"`
|
||||||
Parent string
|
Parent string
|
||||||
Comment string
|
Comment string
|
||||||
Created string
|
Created string
|
||||||
|
@ -99,7 +110,8 @@ type ImageInspect struct {
|
||||||
GraphDriver GraphDriverData
|
GraphDriver GraphDriverData
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET "/containers/json"
|
// Port stores open ports info of container
|
||||||
|
// e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
|
||||||
type Port struct {
|
type Port struct {
|
||||||
IP string `json:",omitempty"`
|
IP string `json:",omitempty"`
|
||||||
PrivatePort int
|
PrivatePort int
|
||||||
|
@ -107,6 +119,8 @@ type Port struct {
|
||||||
Type string
|
Type string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Container contains response of Remote API:
|
||||||
|
// GET "/containers/json"
|
||||||
type Container struct {
|
type Container struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
Names []string
|
Names []string
|
||||||
|
@ -123,14 +137,15 @@ type Container struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CopyConfig contains request body of Remote API:
|
||||||
// POST "/containers/"+containerID+"/copy"
|
// POST "/containers/"+containerID+"/copy"
|
||||||
type CopyConfig struct {
|
type CopyConfig struct {
|
||||||
Resource string
|
Resource string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerPathStat is used to encode the header from
|
// ContainerPathStat is used to encode the header from
|
||||||
// GET /containers/{name:.*}/archive
|
// GET "/containers/{name:.*}/archive"
|
||||||
// "name" is basename of the resource.
|
// "Name" is the file or directory name.
|
||||||
type ContainerPathStat struct {
|
type ContainerPathStat struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Size int64 `json:"size"`
|
Size int64 `json:"size"`
|
||||||
|
@ -139,15 +154,18 @@ type ContainerPathStat struct {
|
||||||
LinkTarget string `json:"linkTarget"`
|
LinkTarget string `json:"linkTarget"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerProcessList contains response of Remote API:
|
||||||
// GET "/containers/{name:.*}/top"
|
// GET "/containers/{name:.*}/top"
|
||||||
type ContainerProcessList struct {
|
type ContainerProcessList struct {
|
||||||
Processes [][]string
|
Processes [][]string
|
||||||
Titles []string
|
Titles []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Version contains response of Remote API:
|
||||||
|
// GET "/version"
|
||||||
type Version struct {
|
type Version struct {
|
||||||
Version string
|
Version string
|
||||||
ApiVersion version.Version
|
APIVersion version.Version `json:"ApiVersion"`
|
||||||
GitCommit string
|
GitCommit string
|
||||||
GoVersion string
|
GoVersion string
|
||||||
Os string
|
Os string
|
||||||
|
@ -157,6 +175,7 @@ type Version struct {
|
||||||
BuildTime string `json:",omitempty"`
|
BuildTime string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Info contains response of Remote API:
|
||||||
// GET "/info"
|
// GET "/info"
|
||||||
type Info struct {
|
type Info struct {
|
||||||
ID string
|
ID string
|
||||||
|
@ -166,11 +185,11 @@ type Info struct {
|
||||||
DriverStatus [][2]string
|
DriverStatus [][2]string
|
||||||
MemoryLimit bool
|
MemoryLimit bool
|
||||||
SwapLimit bool
|
SwapLimit bool
|
||||||
CpuCfsPeriod bool
|
CPUCfsPeriod bool `json:"CpuCfsPeriod"`
|
||||||
CpuCfsQuota bool
|
CPUCfsQuota bool `json:"CpuCfsQuota"`
|
||||||
IPv4Forwarding bool
|
IPv4Forwarding bool
|
||||||
BridgeNfIptables bool
|
BridgeNfIptables bool
|
||||||
BridgeNfIp6tables bool
|
BridgeNfIP6tables bool `json:"BridgeNfIp6tables"`
|
||||||
Debug bool
|
Debug bool
|
||||||
NFd int
|
NFd int
|
||||||
OomKillDisable bool
|
OomKillDisable bool
|
||||||
|
@ -188,15 +207,15 @@ type Info struct {
|
||||||
NCPU int
|
NCPU int
|
||||||
MemTotal int64
|
MemTotal int64
|
||||||
DockerRootDir string
|
DockerRootDir string
|
||||||
HttpProxy string
|
HTTPProxy string `json:"HttpProxy"`
|
||||||
HttpsProxy string
|
HTTPSProxy string `json:"HttpsProxy"`
|
||||||
NoProxy string
|
NoProxy string
|
||||||
Name string
|
Name string
|
||||||
Labels []string
|
Labels []string
|
||||||
ExperimentalBuild bool
|
ExperimentalBuild bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// This struct is a temp struct used by execStart
|
// ExecStartCheck is a temp struct used by execStart
|
||||||
// Config fields is part of ExecConfig in runconfig package
|
// Config fields is part of ExecConfig in runconfig package
|
||||||
type ExecStartCheck struct {
|
type ExecStartCheck struct {
|
||||||
// ExecStart will first check if it's detached
|
// ExecStart will first check if it's detached
|
||||||
|
@ -205,6 +224,8 @@ type ExecStartCheck struct {
|
||||||
Tty bool
|
Tty bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerState stores container's running state
|
||||||
|
// it's part of ContainerJSONBase and will return by "inspect" command
|
||||||
type ContainerState struct {
|
type ContainerState struct {
|
||||||
Running bool
|
Running bool
|
||||||
Paused bool
|
Paused bool
|
||||||
|
@ -218,9 +239,10 @@ type ContainerState struct {
|
||||||
FinishedAt string
|
FinishedAt string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerJSONBase contains response of Remote API:
|
||||||
// GET "/containers/{name:.*}/json"
|
// GET "/containers/{name:.*}/json"
|
||||||
type ContainerJSONBase struct {
|
type ContainerJSONBase struct {
|
||||||
Id string
|
ID string `json:"Id"`
|
||||||
Created string
|
Created string
|
||||||
Path string
|
Path string
|
||||||
Args []string
|
Args []string
|
||||||
|
@ -243,14 +265,15 @@ type ContainerJSONBase struct {
|
||||||
GraphDriver GraphDriverData
|
GraphDriver GraphDriverData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerJSON is newly used struct along with MountPoint
|
||||||
type ContainerJSON struct {
|
type ContainerJSON struct {
|
||||||
*ContainerJSONBase
|
*ContainerJSONBase
|
||||||
Mounts []MountPoint
|
Mounts []MountPoint
|
||||||
Config *runconfig.Config
|
Config *runconfig.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// backcompatibility struct along with ContainerConfig. Note this is not
|
// ContainerJSONPre120 is a backcompatibility struct along with ContainerConfig.
|
||||||
// used by the Windows daemon.
|
// Note this is not used by the Windows daemon.
|
||||||
type ContainerJSONPre120 struct {
|
type ContainerJSONPre120 struct {
|
||||||
*ContainerJSONBase
|
*ContainerJSONBase
|
||||||
Volumes map[string]string
|
Volumes map[string]string
|
||||||
|
@ -258,14 +281,15 @@ type ContainerJSONPre120 struct {
|
||||||
Config *ContainerConfig
|
Config *ContainerConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerConfig is a backcompatibility struct used in ContainerJSONPre120
|
||||||
type ContainerConfig struct {
|
type ContainerConfig struct {
|
||||||
*runconfig.Config
|
*runconfig.Config
|
||||||
|
|
||||||
// backward compatibility, they now live in HostConfig
|
// backward compatibility, they now live in HostConfig
|
||||||
Memory int64
|
Memory int64
|
||||||
MemorySwap int64
|
MemorySwap int64
|
||||||
CpuShares int64
|
CPUShares int64 `json:"CpuShares"`
|
||||||
Cpuset string
|
CPUSet string `json:"CpuSet"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MountPoint represents a mount point configuration inside the container.
|
// MountPoint represents a mount point configuration inside the container.
|
||||||
|
|
|
@ -67,7 +67,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
||||||
DriverStatus: daemon.GraphDriver().Status(),
|
DriverStatus: daemon.GraphDriver().Status(),
|
||||||
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
IPv4Forwarding: !sysInfo.IPv4ForwardingDisabled,
|
||||||
BridgeNfIptables: !sysInfo.BridgeNfCallIptablesDisabled,
|
BridgeNfIptables: !sysInfo.BridgeNfCallIptablesDisabled,
|
||||||
BridgeNfIp6tables: !sysInfo.BridgeNfCallIP6tablesDisabled,
|
BridgeNfIP6tables: !sysInfo.BridgeNfCallIP6tablesDisabled,
|
||||||
Debug: os.Getenv("DEBUG") != "",
|
Debug: os.Getenv("DEBUG") != "",
|
||||||
NFd: fileutils.GetTotalUsedFds(),
|
NFd: fileutils.GetTotalUsedFds(),
|
||||||
NGoroutines: runtime.NumGoroutine(),
|
NGoroutines: runtime.NumGoroutine(),
|
||||||
|
@ -96,15 +96,15 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
|
||||||
v.MemoryLimit = sysInfo.MemoryLimit
|
v.MemoryLimit = sysInfo.MemoryLimit
|
||||||
v.SwapLimit = sysInfo.SwapLimit
|
v.SwapLimit = sysInfo.SwapLimit
|
||||||
v.OomKillDisable = sysInfo.OomKillDisable
|
v.OomKillDisable = sysInfo.OomKillDisable
|
||||||
v.CpuCfsPeriod = sysInfo.CPUCfsPeriod
|
v.CPUCfsPeriod = sysInfo.CPUCfsPeriod
|
||||||
v.CpuCfsQuota = sysInfo.CPUCfsQuota
|
v.CPUCfsQuota = sysInfo.CPUCfsQuota
|
||||||
}
|
}
|
||||||
|
|
||||||
if httpProxy := os.Getenv("http_proxy"); httpProxy != "" {
|
if httpProxy := os.Getenv("http_proxy"); httpProxy != "" {
|
||||||
v.HttpProxy = httpProxy
|
v.HTTPProxy = httpProxy
|
||||||
}
|
}
|
||||||
if httpsProxy := os.Getenv("https_proxy"); httpsProxy != "" {
|
if httpsProxy := os.Getenv("https_proxy"); httpsProxy != "" {
|
||||||
v.HttpsProxy = httpsProxy
|
v.HTTPSProxy = httpsProxy
|
||||||
}
|
}
|
||||||
if noProxy := os.Getenv("no_proxy"); noProxy != "" {
|
if noProxy := os.Getenv("no_proxy"); noProxy != "" {
|
||||||
v.NoProxy = noProxy
|
v.NoProxy = noProxy
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
|
||||||
}
|
}
|
||||||
|
|
||||||
contJSONBase := &types.ContainerJSONBase{
|
contJSONBase := &types.ContainerJSONBase{
|
||||||
Id: container.ID,
|
ID: container.ID,
|
||||||
Created: container.Created.Format(time.RFC3339Nano),
|
Created: container.Created.Format(time.RFC3339Nano),
|
||||||
Path: container.Path,
|
Path: container.Path,
|
||||||
Args: container.Args,
|
Args: container.Args,
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (daemon *Daemon) ContainerStats(name string, config *ContainerStatsConfig)
|
||||||
config.OutStream.Write(nil)
|
config.OutStream.Write(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var preCpuStats types.CpuStats
|
var preCpuStats types.CPUStats
|
||||||
getStat := func(v interface{}) *types.Stats {
|
getStat := func(v interface{}) *types.Stats {
|
||||||
update := v.(*execdriver.ResourceStats)
|
update := v.(*execdriver.ResourceStats)
|
||||||
// Retrieve the nw statistics from libnetwork and inject them in the Stats
|
// Retrieve the nw statistics from libnetwork and inject them in the Stats
|
||||||
|
@ -34,11 +34,11 @@ func (daemon *Daemon) ContainerStats(name string, config *ContainerStatsConfig)
|
||||||
update.Stats.Interfaces = nwStats
|
update.Stats.Interfaces = nwStats
|
||||||
}
|
}
|
||||||
ss := convertStatsToAPITypes(update.Stats)
|
ss := convertStatsToAPITypes(update.Stats)
|
||||||
ss.PreCpuStats = preCpuStats
|
ss.PreCPUStats = preCpuStats
|
||||||
ss.MemoryStats.Limit = uint64(update.MemoryLimit)
|
ss.MemoryStats.Limit = uint64(update.MemoryLimit)
|
||||||
ss.Read = update.Read
|
ss.Read = update.Read
|
||||||
ss.CpuStats.SystemUsage = update.SystemUsage
|
ss.CPUStats.SystemUsage = update.SystemUsage
|
||||||
preCpuStats = ss.CpuStats
|
preCpuStats = ss.CPUStats
|
||||||
return ss
|
return ss
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats {
|
func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats {
|
||||||
s := &types.Stats{}
|
s := &types.Stats{}
|
||||||
if ls.Interfaces != nil {
|
if ls.Interfaces != nil {
|
||||||
s.Network = types.Network{}
|
s.Network = types.NetworkStats{}
|
||||||
for _, iface := range ls.Interfaces {
|
for _, iface := range ls.Interfaces {
|
||||||
s.Network.RxBytes += iface.RxBytes
|
s.Network.RxBytes += iface.RxBytes
|
||||||
s.Network.RxPackets += iface.RxPackets
|
s.Network.RxPackets += iface.RxPackets
|
||||||
|
@ -37,8 +37,8 @@ func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats {
|
||||||
SectorsRecursive: copyBlkioEntry(cs.BlkioStats.SectorsRecursive),
|
SectorsRecursive: copyBlkioEntry(cs.BlkioStats.SectorsRecursive),
|
||||||
}
|
}
|
||||||
cpu := cs.CpuStats
|
cpu := cs.CpuStats
|
||||||
s.CpuStats = types.CpuStats{
|
s.CPUStats = types.CPUStats{
|
||||||
CpuUsage: types.CpuUsage{
|
CPUUsage: types.CPUUsage{
|
||||||
TotalUsage: cpu.CpuUsage.TotalUsage,
|
TotalUsage: cpu.CpuUsage.TotalUsage,
|
||||||
PercpuUsage: cpu.CpuUsage.PercpuUsage,
|
PercpuUsage: cpu.CpuUsage.PercpuUsage,
|
||||||
UsageInKernelmode: cpu.CpuUsage.UsageInKernelmode,
|
UsageInKernelmode: cpu.CpuUsage.UsageInKernelmode,
|
||||||
|
|
|
@ -97,7 +97,7 @@ func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image,
|
||||||
}
|
}
|
||||||
if filtTagged {
|
if filtTagged {
|
||||||
newImage := new(types.Image)
|
newImage := new(types.Image)
|
||||||
newImage.ParentId = image.Parent
|
newImage.ParentID = image.Parent
|
||||||
newImage.ID = image.ID
|
newImage.ID = image.ID
|
||||||
newImage.Created = image.Created.Unix()
|
newImage.Created = image.Created.Unix()
|
||||||
newImage.Size = image.Size
|
newImage.Size = image.Size
|
||||||
|
@ -132,7 +132,7 @@ func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image,
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newImage := new(types.Image)
|
newImage := new(types.Image)
|
||||||
newImage.ParentId = image.Parent
|
newImage.ParentID = image.Parent
|
||||||
newImage.RepoTags = []string{"<none>:<none>"}
|
newImage.RepoTags = []string{"<none>:<none>"}
|
||||||
newImage.RepoDigests = []string{"<none>@<none>"}
|
newImage.RepoDigests = []string{"<none>@<none>"}
|
||||||
newImage.ID = image.ID
|
newImage.ID = image.ID
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (s *TagStore) Lookup(name string) (*types.ImageInspect, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
imageInspect := &types.ImageInspect{
|
imageInspect := &types.ImageInspect{
|
||||||
Id: image.ID,
|
ID: image.ID,
|
||||||
Parent: image.Parent,
|
Parent: image.Parent,
|
||||||
Comment: image.Comment,
|
Comment: image.Comment,
|
||||||
Created: image.Created.Format(time.RFC3339Nano),
|
Created: image.Created.Format(time.RFC3339Nano),
|
||||||
|
|
|
@ -9,9 +9,10 @@ source "${MAKEDIR}/.validate"
|
||||||
|
|
||||||
packages=(
|
packages=(
|
||||||
api
|
api
|
||||||
api/server
|
|
||||||
api/client
|
api/client
|
||||||
api/client/ps
|
api/client/ps
|
||||||
|
api/server
|
||||||
|
api/types
|
||||||
builder
|
builder
|
||||||
builder/command
|
builder/command
|
||||||
builder/parser
|
builder/parser
|
||||||
|
|
|
@ -38,8 +38,12 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
|
func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
|
||||||
s.reg.Close()
|
if s.reg != nil {
|
||||||
s.ds.TearDownTest(c)
|
s.reg.Close()
|
||||||
|
}
|
||||||
|
if s.ds != nil {
|
||||||
|
s.ds.TearDownTest(c)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -1057,11 +1057,11 @@ func (s *DockerSuite) TestContainerApiCreateWithCpuSharesCpuset(c *check.C) {
|
||||||
|
|
||||||
c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil)
|
c.Assert(json.Unmarshal(body, &containerJSON), check.IsNil)
|
||||||
|
|
||||||
out, err := inspectField(containerJSON.Id, "HostConfig.CpuShares")
|
out, err := inspectField(containerJSON.ID, "HostConfig.CpuShares")
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(out, check.Equals, "512")
|
c.Assert(out, check.Equals, "512")
|
||||||
|
|
||||||
outCpuset, errCpuset := inspectField(containerJSON.Id, "HostConfig.CpusetCpus")
|
outCpuset, errCpuset := inspectField(containerJSON.ID, "HostConfig.CpusetCpus")
|
||||||
c.Assert(errCpuset, check.IsNil, check.Commentf("Output: %s", outCpuset))
|
c.Assert(errCpuset, check.IsNil, check.Commentf("Output: %s", outCpuset))
|
||||||
c.Assert(outCpuset, check.Equals, "0,1")
|
c.Assert(outCpuset, check.Equals, "0,1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ func (s *DockerSuite) TestCliStatsNoStreamGetCpu(c *check.C) {
|
||||||
body.Close()
|
body.Close()
|
||||||
|
|
||||||
var cpuPercent = 0.0
|
var cpuPercent = 0.0
|
||||||
cpuDelta := float64(v.CpuStats.CpuUsage.TotalUsage - v.PreCpuStats.CpuUsage.TotalUsage)
|
cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
|
||||||
systemDelta := float64(v.CpuStats.SystemUsage - v.PreCpuStats.SystemUsage)
|
systemDelta := float64(v.CPUStats.SystemUsage - v.PreCPUStats.SystemUsage)
|
||||||
cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) * 100.0
|
cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CPUStats.CPUUsage.PercpuUsage)) * 100.0
|
||||||
if cpuPercent == 0 {
|
if cpuPercent == 0 {
|
||||||
c.Fatalf("docker stats with no-stream get cpu usage failed: was %v", cpuPercent)
|
c.Fatalf("docker stats with no-stream get cpu usage failed: was %v", cpuPercent)
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ func (s *DockerSuite) TestApiNetworkStats(c *check.C) {
|
||||||
check.Commentf("Reported less Txbytes than expected. Expected >= %d. Found %d. %s", expRxPkts, nwStatsPost.RxPackets, pingouts))
|
check.Commentf("Reported less Txbytes than expected. Expected >= %d. Found %d. %s", expRxPkts, nwStatsPost.RxPackets, pingouts))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNetworkStats(c *check.C, id string) types.Network {
|
func getNetworkStats(c *check.C, id string) types.NetworkStats {
|
||||||
var st *types.Stats
|
var st *types.Stats
|
||||||
|
|
||||||
_, body, err := sockRequestRaw("GET", fmt.Sprintf("/containers/%s/stats?stream=false", id), nil, "")
|
_, body, err := sockRequestRaw("GET", fmt.Sprintf("/containers/%s/stats?stream=false", id), nil, "")
|
||||||
|
|
Loading…
Reference in a new issue