Port client lib from samalba/dockerclient to docker/docker/client

This commit is contained in:
Ross Cadogan 2016-10-13 21:34:24 +01:00
parent 25f1fee8e2
commit 99ed959155
4 changed files with 74 additions and 61 deletions

View file

@ -4,7 +4,8 @@ import (
"fmt"
"strings"
"github.com/samalba/dockerclient"
"github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"
)
const (
@ -15,7 +16,7 @@ const (
// NewContainer returns a new Container instance instantiated with the
// specified ContainerInfo and ImageInfo structs.
func NewContainer(containerInfo *dockerclient.ContainerInfo, imageInfo *dockerclient.ImageInfo) *Container {
func NewContainer(containerInfo *types.ContainerJSON, imageInfo *types.ImageInspect) *Container {
return &Container{
containerInfo: containerInfo,
imageInfo: imageInfo,
@ -26,13 +27,13 @@ func NewContainer(containerInfo *dockerclient.ContainerInfo, imageInfo *dockercl
type Container struct {
Stale bool
containerInfo *dockerclient.ContainerInfo
imageInfo *dockerclient.ImageInfo
containerInfo *types.ContainerJSON
imageInfo *types.ImageInspect
}
// ID returns the Docker container ID.
func (c Container) ID() string {
return c.containerInfo.Id
return c.containerInfo.ID
}
// Name returns the Docker container name.
@ -43,7 +44,7 @@ func (c Container) Name() string {
// ImageID returns the ID of the Docker image that was used to start the
// container.
func (c Container) ImageID() string {
return c.imageInfo.Id
return c.imageInfo.ID
}
// ImageName returns the name of the Docker image that was used to start the
@ -109,7 +110,7 @@ func (c Container) StopSignal() string {
// running container with the ContainerConfig from the image that container was
// started from. This function returns a ContainerConfig which contains just
// the options overridden at runtime.
func (c Container) runtimeConfig() *dockerclient.ContainerConfig {
func (c Container) runtimeConfig() *dockercontainer.Config {
config := c.containerInfo.Config
imageConfig := c.imageInfo.Config
@ -135,7 +136,7 @@ func (c Container) runtimeConfig() *dockerclient.ContainerConfig {
config.Volumes = structMapSubtract(config.Volumes, imageConfig.Volumes)
config.ExposedPorts = structMapSubtract(config.ExposedPorts, imageConfig.ExposedPorts)
config.ExposedPorts = structMapPortSubtract(config.ExposedPorts, imageConfig.ExposedPorts)
for p := range c.containerInfo.HostConfig.PortBindings {
config.ExposedPorts[p] = struct{}{}
}
@ -146,7 +147,7 @@ func (c Container) runtimeConfig() *dockerclient.ContainerConfig {
// Any links in the HostConfig need to be re-written before they can be
// re-submitted to the Docker create API.
func (c Container) hostConfig() *dockerclient.HostConfig {
func (c Container) hostConfig() *dockercontainer.HostConfig {
hostConfig := c.containerInfo.HostConfig
for i, link := range hostConfig.Links {