Move docker types to v1 API

This commit is contained in:
Tim St. Clair 2016-05-02 15:52:29 -07:00
parent 9961e37168
commit f365c6a115
5 changed files with 16 additions and 16 deletions

View File

@ -20,23 +20,24 @@ import (
"strconv" "strconv"
"strings" "strings"
dockertypes "github.com/docker/engine-api/types"
"golang.org/x/net/context" "golang.org/x/net/context"
dockertypes "github.com/docker/engine-api/types" "github.com/google/cadvisor/info/v1"
"github.com/google/cadvisor/utils/machine" "github.com/google/cadvisor/utils/machine"
) )
func Status() (DockerStatus, error) { func Status() (v1.DockerStatus, error) {
client, err := Client() client, err := Client()
if err != nil { if err != nil {
return DockerStatus{}, fmt.Errorf("unable to communicate with docker daemon: %v", err) return v1.DockerStatus{}, fmt.Errorf("unable to communicate with docker daemon: %v", err)
} }
dockerInfo, err := client.Info(context.Background()) dockerInfo, err := client.Info(context.Background())
if err != nil { if err != nil {
return DockerStatus{}, err return v1.DockerStatus{}, err
} }
out := DockerStatus{} out := v1.DockerStatus{}
out.Version = VersionString() out.Version = VersionString()
out.KernelVersion = machine.KernelVersion() out.KernelVersion = machine.KernelVersion()
out.OS = dockerInfo.OperatingSystem out.OS = dockerInfo.OperatingSystem
@ -53,7 +54,7 @@ func Status() (DockerStatus, error) {
return out, nil return out, nil
} }
func Images() ([]DockerImage, error) { func Images() ([]v1.DockerImage, error) {
client, err := Client() client, err := Client()
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to communicate with docker daemon: %v", err) return nil, fmt.Errorf("unable to communicate with docker daemon: %v", err)
@ -63,14 +64,14 @@ func Images() ([]DockerImage, error) {
return nil, err return nil, err
} }
out := []DockerImage{} out := []v1.DockerImage{}
const unknownTag = "<none>:<none>" const unknownTag = "<none>:<none>"
for _, image := range images { for _, image := range images {
if len(image.RepoTags) == 1 && image.RepoTags[0] == unknownTag { if len(image.RepoTags) == 1 && image.RepoTags[0] == unknownTag {
// images with repo or tags are uninteresting. // images with repo or tags are uninteresting.
continue continue
} }
di := DockerImage{ di := v1.DockerImage{
ID: image.ID, ID: image.ID,
RepoTags: image.RepoTags, RepoTags: image.RepoTags,
Created: image.Created, Created: image.Created,

View File

@ -13,7 +13,7 @@
// limitations under the License. // limitations under the License.
// Types used for docker containers. // Types used for docker containers.
package docker package v1
type DockerStatus struct { type DockerStatus struct {
Version string `json:"version"` Version string `json:"version"`

View File

@ -112,10 +112,10 @@ type Manager interface {
CloseEventChannel(watch_id int) CloseEventChannel(watch_id int)
// Get status information about docker. // Get status information about docker.
DockerInfo() (docker.DockerStatus, error) DockerInfo() (info.DockerStatus, error)
// Get details about interesting docker images. // Get details about interesting docker images.
DockerImages() ([]docker.DockerImage, error) DockerImages() ([]info.DockerImage, error)
// Returns debugging information. Map of lines per category. // Returns debugging information. Map of lines per category.
DebugInfo() map[string][]string DebugInfo() map[string][]string
@ -1124,11 +1124,11 @@ func parseEventsStoragePolicy() events.StoragePolicy {
return policy return policy
} }
func (m *manager) DockerImages() ([]docker.DockerImage, error) { func (m *manager) DockerImages() ([]info.DockerImage, error) {
return docker.Images() return docker.Images()
} }
func (m *manager) DockerInfo() (docker.DockerStatus, error) { func (m *manager) DockerInfo() (info.DockerStatus, error) {
return docker.Status() return docker.Status()
} }

View File

@ -31,7 +31,7 @@ import (
const DockerPage = "/docker/" const DockerPage = "/docker/"
func toStatusKV(status docker.DockerStatus) ([]keyVal, []keyVal) { func toStatusKV(status info.DockerStatus) ([]keyVal, []keyVal) {
ds := []keyVal{ ds := []keyVal{
{Key: "Driver", Value: status.Driver}, {Key: "Driver", Value: status.Driver},
} }

View File

@ -21,7 +21,6 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/google/cadvisor/container/docker"
httpmux "github.com/google/cadvisor/http/mux" httpmux "github.com/google/cadvisor/http/mux"
info "github.com/google/cadvisor/info/v1" info "github.com/google/cadvisor/info/v1"
"github.com/google/cadvisor/manager" "github.com/google/cadvisor/manager"
@ -63,7 +62,7 @@ type pageData struct {
Root string Root string
DockerStatus []keyVal DockerStatus []keyVal
DockerDriverStatus []keyVal DockerDriverStatus []keyVal
DockerImages []docker.DockerImage DockerImages []info.DockerImage
} }
func init() { func init() {