Explorar el Código

fix golint warnings/errors on package api/types/

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Zhang Wei hace 10 años
padre
commit
3d6617ffe7

+ 3 - 3
api/client/info.go

@@ -61,8 +61,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 		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, "Https Proxy: %s\n", info.HttpsProxy)
+	ioutils.FprintfIfNotEmpty(cli.out, "Http Proxy: %s\n", info.HTTPProxy)
+	ioutils.FprintfIfNotEmpty(cli.out, "Https Proxy: %s\n", info.HTTPSProxy)
 	ioutils.FprintfIfNotEmpty(cli.out, "No Proxy: %s\n", info.NoProxy)
 
 	if info.IndexServerAddress != "" {
@@ -87,7 +87,7 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 			if !info.BridgeNfIptables {
 				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")
 			}
 		}

+ 5 - 5
api/client/stats.go

@@ -65,8 +65,8 @@ func (s *containerStats) Collect(cli *DockerCli, streamStats bool) {
 				memPercent = float64(v.MemoryStats.Usage) / float64(v.MemoryStats.Limit) * 100.0
 				cpuPercent = 0.0
 			)
-			previousCPU = v.PreCpuStats.CpuUsage.TotalUsage
-			previousSystem = v.PreCpuStats.SystemUsage
+			previousCPU = v.PreCPUStats.CPUUsage.TotalUsage
+			previousSystem = v.PreCPUStats.SystemUsage
 			cpuPercent = calculateCPUPercent(previousCPU, previousSystem, v)
 			blkRead, blkWrite := calculateBlockIO(v.BlkioStats)
 			s.mu.Lock()
@@ -196,13 +196,13 @@ func calculateCPUPercent(previousCPU, previousSystem uint64, v *types.Stats) flo
 	var (
 		cpuPercent = 0.0
 		// 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
-		systemDelta = float64(v.CpuStats.SystemUsage - previousSystem)
+		systemDelta = float64(v.CPUStats.SystemUsage - previousSystem)
 	)
 
 	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
 }

+ 3 - 3
api/client/version.go

@@ -15,7 +15,7 @@ import (
 
 var versionTemplate = `Client:
  Version:      {{.Client.Version}}
- API version:  {{.Client.ApiVersion}}
+ API version:  {{.Client.APIVersion}}
  Go version:   {{.Client.GoVersion}}
  Git commit:   {{.Client.GitCommit}}
  Built:        {{.Client.BuildTime}}
@@ -24,7 +24,7 @@ var versionTemplate = `Client:
 
 Server:
  Version:      {{.Server.Version}}
- API version:  {{.Server.ApiVersion}}
+ API version:  {{.Server.APIVersion}}
  Go version:   {{.Server.GoVersion}}
  Git commit:   {{.Server.GitCommit}}
  Built:        {{.Server.BuildTime}}
@@ -61,7 +61,7 @@ func (cli *DockerCli) CmdVersion(args ...string) (err error) {
 	vd := versionData{
 		Client: types.Version{
 			Version:      dockerversion.VERSION,
-			ApiVersion:   api.Version,
+			APIVersion:   api.Version,
 			GoVersion:    runtime.Version(),
 			GitCommit:    dockerversion.GITCOMMIT,
 			BuildTime:    dockerversion.BUILDTIME,

+ 1 - 1
api/server/daemon.go

@@ -23,7 +23,7 @@ import (
 func (s *Server) getVersion(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
 	v := &types.Version{
 		Version:    dockerversion.VERSION,
-		ApiVersion: api.Version,
+		APIVersion: api.Version,
 		GitCommit:  dockerversion.GITCOMMIT,
 		GoVersion:  runtime.Version(),
 		Os:         runtime.GOOS,

+ 19 - 12
api/types/stats.go

@@ -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.
 package types
 
 import "time"
 
+// ThrottlingData stores CPU throttling stats of one running container
 type ThrottlingData struct {
 	// Number of periods with throttling active
 	Periods uint64 `json:"periods"`
@@ -13,8 +14,8 @@ type ThrottlingData struct {
 	ThrottledTime uint64 `json:"throttled_time"`
 }
 
-// All CPU stats are aggregated since container inception.
-type CpuUsage struct {
+// CPUUsage stores All CPU stats aggregated since container inception.
+type CPUUsage struct {
 	// Total CPU time consumed.
 	// Units: nanoseconds.
 	TotalUsage uint64 `json:"total_usage"`
@@ -29,12 +30,14 @@ type CpuUsage struct {
 	UsageInUsermode uint64 `json:"usage_in_usermode"`
 }
 
-type CpuStats struct {
-	CpuUsage       CpuUsage       `json:"cpu_usage"`
+// CPUStats aggregates and wraps all CPU related info of container
+type CPUStats struct {
+	CPUUsage       CPUUsage       `json:"cpu_usage"`
 	SystemUsage    uint64         `json:"system_cpu_usage"`
 	ThrottlingData ThrottlingData `json:"throttling_data,omitempty"`
 }
 
+// MemoryStats aggregates All memory stats since container inception
 type MemoryStats struct {
 	// current res_counter usage for memory
 	Usage uint64 `json:"usage"`
@@ -48,6 +51,7 @@ type MemoryStats struct {
 	Limit   uint64 `json:"limit"`
 }
 
+// BlkioStatEntry is one small entity to store a piece of Blkio stats
 // TODO Windows: This can be factored out
 type BlkioStatEntry struct {
 	Major uint64 `json:"major"`
@@ -56,6 +60,7 @@ type BlkioStatEntry struct {
 	Value uint64 `json:"value"`
 }
 
+// BlkioStats stores All IO service stats for data read and write
 // TODO Windows: This can be factored out
 type BlkioStats struct {
 	// number of bytes tranferred to and from the block device
@@ -69,8 +74,9 @@ type BlkioStats struct {
 	SectorsRecursive        []BlkioStatEntry `json:"sectors_recursive"`
 }
 
+// NetworkStats aggregates All network stats of one container
 // TODO Windows: This will require refactoring
-type Network struct {
+type NetworkStats struct {
 	RxBytes   uint64 `json:"rx_bytes"`
 	RxPackets uint64 `json:"rx_packets"`
 	RxErrors  uint64 `json:"rx_errors"`
@@ -81,11 +87,12 @@ type Network struct {
 	TxDropped uint64 `json:"tx_dropped"`
 }
 
+// Stats is Ultimate struct aggregating all types of stats of one container
 type Stats struct {
-	Read        time.Time   `json:"read"`
-	Network     Network     `json:"network,omitempty"`
-	PreCpuStats CpuStats    `json:"precpu_stats,omitempty"`
-	CpuStats    CpuStats    `json:"cpu_stats,omitempty"`
-	MemoryStats MemoryStats `json:"memory_stats,omitempty"`
-	BlkioStats  BlkioStats  `json:"blkio_stats,omitempty"`
+	Read        time.Time    `json:"read"`
+	Network     NetworkStats `json:"network,omitempty"`
+	PreCPUStats CPUStats     `json:"precpu_stats,omitempty"`
+	CPUStats    CPUStats     `json:"cpu_stats,omitempty"`
+	MemoryStats MemoryStats  `json:"memory_stats,omitempty"`
+	BlkioStats  BlkioStats   `json:"blkio_stats,omitempty"`
 }

+ 43 - 19
api/types/types.go

@@ -19,35 +19,41 @@ type ContainerCreateResponse struct {
 	Warnings []string `json:"Warnings"`
 }
 
-// POST /containers/{name:.*}/exec
+// ContainerExecCreateResponse contains response of Remote API:
+// POST "/containers/{name:.*}/exec"
 type ContainerExecCreateResponse struct {
 	// ID is the exec ID.
 	ID string `json:"Id"`
 }
 
-// POST /auth
+// AuthResponse contains response of Remote API:
+// POST "/auth"
 type AuthResponse struct {
 	// Status is the authentication status
 	Status string `json:"Status"`
 }
 
+// ContainerWaitResponse contains response of Remote API:
 // POST "/containers/"+containerID+"/wait"
 type ContainerWaitResponse struct {
 	// StatusCode is the status code of the wait job
 	StatusCode int `json:"StatusCode"`
 }
 
+// ContainerCommitResponse contains response of Remote API:
 // POST "/commit?container="+containerID
 type ContainerCommitResponse struct {
 	ID string `json:"Id"`
 }
 
+// ContainerChange contains response of Remote API:
 // GET "/containers/{name:.*}/changes"
 type ContainerChange struct {
 	Kind int
 	Path string
 }
 
+// ImageHistory contains response of Remote API:
 // GET "/images/{name:.*}/history"
 type ImageHistory struct {
 	ID        string `json:"Id"`
@@ -58,16 +64,18 @@ type ImageHistory struct {
 	Comment   string
 }
 
+// ImageDelete contains response of Remote API:
 // DELETE "/images/{name:.*}"
 type ImageDelete struct {
 	Untagged string `json:",omitempty"`
 	Deleted  string `json:",omitempty"`
 }
 
+// Image contains response of Remote API:
 // GET "/images/json"
 type Image struct {
 	ID          string `json:"Id"`
-	ParentId    string
+	ParentID    string `json:"ParentId"`
 	RepoTags    []string
 	RepoDigests []string
 	Created     int64
@@ -76,14 +84,17 @@ type Image struct {
 	Labels      map[string]string
 }
 
+// GraphDriverData returns Image's graph driver config info
+// when calling inspect command
 type GraphDriverData struct {
 	Name string
 	Data map[string]string
 }
 
+// ImageInspect contains response of Remote API:
 // GET "/images/{name:.*}/json"
 type ImageInspect struct {
-	Id              string
+	ID              string `json:"Id"`
 	Parent          string
 	Comment         string
 	Created         string
@@ -99,7 +110,8 @@ type ImageInspect struct {
 	GraphDriver     GraphDriverData
 }
 
-// GET  "/containers/json"
+// Port stores open ports info of container
+// e.g. {"PrivatePort": 8080, "PublicPort": 80, "Type": "tcp"}
 type Port struct {
 	IP          string `json:",omitempty"`
 	PrivatePort int
@@ -107,6 +119,8 @@ type Port struct {
 	Type        string
 }
 
+// Container contains response of Remote API:
+// GET  "/containers/json"
 type Container struct {
 	ID         string `json:"Id"`
 	Names      []string
@@ -123,14 +137,15 @@ type Container struct {
 	}
 }
 
+// CopyConfig contains request body of Remote API:
 // POST "/containers/"+containerID+"/copy"
 type CopyConfig struct {
 	Resource string
 }
 
 // ContainerPathStat is used to encode the header from
-// 	GET /containers/{name:.*}/archive
-// "name" is basename of the resource.
+// GET "/containers/{name:.*}/archive"
+// "Name" is the file or directory name.
 type ContainerPathStat struct {
 	Name       string      `json:"name"`
 	Size       int64       `json:"size"`
@@ -139,15 +154,18 @@ type ContainerPathStat struct {
 	LinkTarget string      `json:"linkTarget"`
 }
 
+// ContainerProcessList contains response of Remote API:
 // GET "/containers/{name:.*}/top"
 type ContainerProcessList struct {
 	Processes [][]string
 	Titles    []string
 }
 
+// Version contains response of Remote API:
+// GET "/version"
 type Version struct {
 	Version       string
-	ApiVersion    version.Version
+	APIVersion    version.Version `json:"ApiVersion"`
 	GitCommit     string
 	GoVersion     string
 	Os            string
@@ -157,6 +175,7 @@ type Version struct {
 	BuildTime     string `json:",omitempty"`
 }
 
+// Info contains response of Remote API:
 // GET "/info"
 type Info struct {
 	ID                 string
@@ -166,11 +185,11 @@ type Info struct {
 	DriverStatus       [][2]string
 	MemoryLimit        bool
 	SwapLimit          bool
-	CpuCfsPeriod       bool
-	CpuCfsQuota        bool
+	CPUCfsPeriod       bool `json:"CpuCfsPeriod"`
+	CPUCfsQuota        bool `json:"CpuCfsQuota"`
 	IPv4Forwarding     bool
 	BridgeNfIptables   bool
-	BridgeNfIp6tables  bool
+	BridgeNfIP6tables  bool `json:"BridgeNfIp6tables"`
 	Debug              bool
 	NFd                int
 	OomKillDisable     bool
@@ -188,15 +207,15 @@ type Info struct {
 	NCPU               int
 	MemTotal           int64
 	DockerRootDir      string
-	HttpProxy          string
-	HttpsProxy         string
+	HTTPProxy          string `json:"HttpProxy"`
+	HTTPSProxy         string `json:"HttpsProxy"`
 	NoProxy            string
 	Name               string
 	Labels             []string
 	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
 type ExecStartCheck struct {
 	// ExecStart will first check if it's detached
@@ -205,6 +224,8 @@ type ExecStartCheck struct {
 	Tty bool
 }
 
+// ContainerState stores container's running state
+// it's part of ContainerJSONBase and will return by "inspect" command
 type ContainerState struct {
 	Running    bool
 	Paused     bool
@@ -218,9 +239,10 @@ type ContainerState struct {
 	FinishedAt string
 }
 
+// ContainerJSONBase contains response of Remote API:
 // GET "/containers/{name:.*}/json"
 type ContainerJSONBase struct {
-	Id              string
+	ID              string `json:"Id"`
 	Created         string
 	Path            string
 	Args            []string
@@ -243,14 +265,15 @@ type ContainerJSONBase struct {
 	GraphDriver     GraphDriverData
 }
 
+// ContainerJSON is newly used struct along with MountPoint
 type ContainerJSON struct {
 	*ContainerJSONBase
 	Mounts []MountPoint
 	Config *runconfig.Config
 }
 
-// backcompatibility struct along with ContainerConfig. Note this is not
-// used by the Windows daemon.
+// ContainerJSONPre120 is a backcompatibility struct along with ContainerConfig.
+// Note this is not used by the Windows daemon.
 type ContainerJSONPre120 struct {
 	*ContainerJSONBase
 	Volumes   map[string]string
@@ -258,14 +281,15 @@ type ContainerJSONPre120 struct {
 	Config    *ContainerConfig
 }
 
+// ContainerConfig is a backcompatibility struct used in ContainerJSONPre120
 type ContainerConfig struct {
 	*runconfig.Config
 
 	// backward compatibility, they now live in HostConfig
 	Memory     int64
 	MemorySwap int64
-	CpuShares  int64
-	Cpuset     string
+	CPUShares  int64  `json:"CpuShares"`
+	CPUSet     string `json:"CpuSet"`
 }
 
 // MountPoint represents a mount point configuration inside the container.

+ 5 - 5
daemon/info.go

@@ -67,7 +67,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		DriverStatus:       daemon.GraphDriver().Status(),
 		IPv4Forwarding:     !sysInfo.IPv4ForwardingDisabled,
 		BridgeNfIptables:   !sysInfo.BridgeNfCallIptablesDisabled,
-		BridgeNfIp6tables:  !sysInfo.BridgeNfCallIP6tablesDisabled,
+		BridgeNfIP6tables:  !sysInfo.BridgeNfCallIP6tablesDisabled,
 		Debug:              os.Getenv("DEBUG") != "",
 		NFd:                fileutils.GetTotalUsedFds(),
 		NGoroutines:        runtime.NumGoroutine(),
@@ -96,15 +96,15 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
 		v.MemoryLimit = sysInfo.MemoryLimit
 		v.SwapLimit = sysInfo.SwapLimit
 		v.OomKillDisable = sysInfo.OomKillDisable
-		v.CpuCfsPeriod = sysInfo.CPUCfsPeriod
-		v.CpuCfsQuota = sysInfo.CPUCfsQuota
+		v.CPUCfsPeriod = sysInfo.CPUCfsPeriod
+		v.CPUCfsQuota = sysInfo.CPUCfsQuota
 	}
 
 	if httpProxy := os.Getenv("http_proxy"); httpProxy != "" {
-		v.HttpProxy = httpProxy
+		v.HTTPProxy = httpProxy
 	}
 	if httpsProxy := os.Getenv("https_proxy"); httpsProxy != "" {
-		v.HttpsProxy = httpsProxy
+		v.HTTPSProxy = httpsProxy
 	}
 	if noProxy := os.Getenv("no_proxy"); noProxy != "" {
 		v.NoProxy = noProxy

+ 1 - 1
daemon/inspect.go

@@ -55,7 +55,7 @@ func (daemon *Daemon) getInspectData(container *Container) (*types.ContainerJSON
 	}
 
 	contJSONBase := &types.ContainerJSONBase{
-		Id:              container.ID,
+		ID:              container.ID,
 		Created:         container.Created.Format(time.RFC3339Nano),
 		Path:            container.Path,
 		Args:            container.Args,

+ 4 - 4
daemon/stats.go

@@ -26,7 +26,7 @@ func (daemon *Daemon) ContainerStats(name string, config *ContainerStatsConfig)
 		config.OutStream.Write(nil)
 	}
 
-	var preCpuStats types.CpuStats
+	var preCpuStats types.CPUStats
 	getStat := func(v interface{}) *types.Stats {
 		update := v.(*execdriver.ResourceStats)
 		// 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
 		}
 		ss := convertStatsToAPITypes(update.Stats)
-		ss.PreCpuStats = preCpuStats
+		ss.PreCPUStats = preCpuStats
 		ss.MemoryStats.Limit = uint64(update.MemoryLimit)
 		ss.Read = update.Read
-		ss.CpuStats.SystemUsage = update.SystemUsage
-		preCpuStats = ss.CpuStats
+		ss.CPUStats.SystemUsage = update.SystemUsage
+		preCpuStats = ss.CPUStats
 		return ss
 	}
 

+ 3 - 3
daemon/stats_linux.go

@@ -11,7 +11,7 @@ import (
 func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats {
 	s := &types.Stats{}
 	if ls.Interfaces != nil {
-		s.Network = types.Network{}
+		s.Network = types.NetworkStats{}
 		for _, iface := range ls.Interfaces {
 			s.Network.RxBytes += iface.RxBytes
 			s.Network.RxPackets += iface.RxPackets
@@ -37,8 +37,8 @@ func convertStatsToAPITypes(ls *libcontainer.Stats) *types.Stats {
 			SectorsRecursive:        copyBlkioEntry(cs.BlkioStats.SectorsRecursive),
 		}
 		cpu := cs.CpuStats
-		s.CpuStats = types.CpuStats{
-			CpuUsage: types.CpuUsage{
+		s.CPUStats = types.CPUStats{
+			CPUUsage: types.CPUUsage{
 				TotalUsage:        cpu.CpuUsage.TotalUsage,
 				PercpuUsage:       cpu.CpuUsage.PercpuUsage,
 				UsageInKernelmode: cpu.CpuUsage.UsageInKernelmode,

+ 2 - 2
graph/list.go

@@ -97,7 +97,7 @@ func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image,
 				}
 				if filtTagged {
 					newImage := new(types.Image)
-					newImage.ParentId = image.Parent
+					newImage.ParentID = image.Parent
 					newImage.ID = image.ID
 					newImage.Created = image.Created.Unix()
 					newImage.Size = image.Size
@@ -132,7 +132,7 @@ func (s *TagStore) Images(filterArgs, filter string, all bool) ([]*types.Image,
 				continue
 			}
 			newImage := new(types.Image)
-			newImage.ParentId = image.Parent
+			newImage.ParentID = image.Parent
 			newImage.RepoTags = []string{"<none>:<none>"}
 			newImage.RepoDigests = []string{"<none>@<none>"}
 			newImage.ID = image.ID

+ 1 - 1
graph/service.go

@@ -35,7 +35,7 @@ func (s *TagStore) Lookup(name string) (*types.ImageInspect, error) {
 	}
 
 	imageInspect := &types.ImageInspect{
-		Id:              image.ID,
+		ID:              image.ID,
 		Parent:          image.Parent,
 		Comment:         image.Comment,
 		Created:         image.Created.Format(time.RFC3339Nano),

+ 2 - 1
hack/make/validate-lint

@@ -9,9 +9,10 @@ source "${MAKEDIR}/.validate"
 
 packages=(
 	api
-	api/server
 	api/client
 	api/client/ps
+	api/server
+	api/types
 	builder
 	builder/command
 	builder/parser

+ 6 - 2
integration-cli/check_test.go

@@ -38,8 +38,12 @@ func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
 }
 
 func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
-	s.reg.Close()
-	s.ds.TearDownTest(c)
+	if s.reg != nil {
+		s.reg.Close()
+	}
+	if s.ds != nil {
+		s.ds.TearDownTest(c)
+	}
 }
 
 func init() {

+ 2 - 2
integration-cli/docker_api_containers_test.go

@@ -1057,11 +1057,11 @@ func (s *DockerSuite) TestContainerApiCreateWithCpuSharesCpuset(c *check.C) {
 
 	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(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(outCpuset, check.Equals, "0,1")
 }

+ 4 - 4
integration-cli/docker_api_stats_test.go

@@ -31,9 +31,9 @@ func (s *DockerSuite) TestCliStatsNoStreamGetCpu(c *check.C) {
 	body.Close()
 
 	var cpuPercent = 0.0
-	cpuDelta := float64(v.CpuStats.CpuUsage.TotalUsage - v.PreCpuStats.CpuUsage.TotalUsage)
-	systemDelta := float64(v.CpuStats.SystemUsage - v.PreCpuStats.SystemUsage)
-	cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CpuStats.CpuUsage.PercpuUsage)) * 100.0
+	cpuDelta := float64(v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage)
+	systemDelta := float64(v.CPUStats.SystemUsage - v.PreCPUStats.SystemUsage)
+	cpuPercent = (cpuDelta / systemDelta) * float64(len(v.CPUStats.CPUUsage.PercpuUsage)) * 100.0
 	if cpuPercent == 0 {
 		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))
 }
 
-func getNetworkStats(c *check.C, id string) types.Network {
+func getNetworkStats(c *check.C, id string) types.NetworkStats {
 	var st *types.Stats
 
 	_, body, err := sockRequestRaw("GET", fmt.Sprintf("/containers/%s/stats?stream=false", id), nil, "")