dockertools

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const DockerDefaultAddress = "unix:///var/run/docker.sock"

DockerDefaultAddress is default address for docker

View Source
const EMPTYVALUE byte = 0

EMPTYVALUE is byte type for zero value

View Source
const PROJECTNAME = "southchina"

PROJECTNAME needs to be specified, temporarily written as "southchina"

View Source
const (

	//ZeroTime defines base time
	ZeroTime = "0001-01-01T00:00:00Z"
)

Variables

View Source
var (
	// ErrImageNeverPull : Required Image is absent on host and PullPolicy is NeverPullImage
	ErrImageNeverPull = errors.New("ErrImageNeverPull")
	// DockerAddress is address for docker
	DockerAddress = DockerDefaultAddress
)
View Source
var ImagePullError error

ImagePullError is var of error type

Functions

func InitDockerAddress added in v0.3.0

func InitDockerAddress(dockerAddress string)

InitDockerAddress inits docker address

func IsImageNotFoundError

func IsImageNotFoundError(err error) bool

IsImageNotFoundError checks error to be of type imageNotFoundError

func NewDockerClient

func NewDockerClient(dockerEndpoint string) (dockerapi.CommonAPIClient, error)

NewDockerClient gets a *dockerapi.Client, either using the endpoint passed in, or using DOCKER_HOST, DOCKER_TLS_VERIFY, and DOCKER_CERT path per their spec

func NewDockerConfig

func NewDockerConfig() *dockershim.ClientConfig

NewDockerConfig configures docker client TODO: fillup other field in this struct

Types

type DockerConfig

type DockerConfig map[string]DockerConfigEntry

DockerConfig represents the config file used by the docker CLI. This config that represents the credentials that should be used when pulling images from specific image repositories.

type DockerConfigEntry

type DockerConfigEntry struct {
	Username string
	Password string
	Email    string
}

DockerConfigEntry defines

func (DockerConfigEntry) MarshalJSON

func (ident DockerConfigEntry) MarshalJSON() ([]byte, error)

MarshalJSON is to encode byte array to json

func (*DockerConfigEntry) UnmarshalJSON

func (ident *DockerConfigEntry) UnmarshalJSON(data []byte) error

UnmarshalJSON is to unmarshal json object

type DockerConfigJSON

type DockerConfigJSON struct {
	Auths DockerConfig `json:"auths"`
	// +optional
	HTTPHeaders map[string]string `json:"HttpHeaders,omitempty"`
}

DockerConfigJSON is json struct for docker configuration

type DockerManager

type DockerManager struct {
	containers.ContainerManager
	// contains filtered or unexported fields
}

DockerManager defines object structure of docker manager

func NewDockerManager

func NewDockerManager(livenessManager proberesults.Manager, qps float32, burst int, backOff *flowcontrol.Backoff, serializeImagePulls bool, devicePluginEnabled bool, gpuManager gpu.GPUManager, interfaceName string) (*DockerManager, error)

NewDockerManager returns a docker manager object

func (*DockerManager) APIVersion

func (dm *DockerManager) APIVersion() (kubecontainer.Version, error)

APIVersion returns docker version

func (*DockerManager) ContainerStatus

func (dm *DockerManager) ContainerStatus(containerID string) (*cri.ContainerStatus, error)

ContainerStatus gives container status

func (*DockerManager) CreateContainer

func (dm *DockerManager) CreateContainer(config *cri.ContainerConfig) (string, error)

CreateContainer creates container and returns ID

func (*DockerManager) DeleteContainer

func (dm *DockerManager) DeleteContainer(containerID kubecontainer.ContainerID) error

DeleteContainer deletes container given ID

func (*DockerManager) EnsureImageExists

func (dm *DockerManager) EnsureImageExists(pod *v1.Pod, secrets []v1.Secret) error

EnsureImageExists checks existence of image in container

func (*DockerManager) GetContainerLogs

func (dm *DockerManager) GetContainerLogs(pod *v1.Pod, containerID kubecontainer.ContainerID, logOptions *v1.PodLogOptions, stdout, stderr io.Writer) (err error)

GetContainerLogs returns logs of a specific container. By default, it returns a snapshot of the container log.

func (*DockerManager) GetImageRef

func (dm *DockerManager) GetImageRef(image kubecontainer.ImageSpec) (string, error)

GetImageRef is part of interface.

func (*DockerManager) GetNetNS

func (dm *DockerManager) GetNetNS(containerID kubecontainer.ContainerID) (string, error)

GetNetNS returns the network namespace path for the given container

func (*DockerManager) GetPodContainerID

func (dm *DockerManager) GetPodContainerID(*kubecontainer.Pod) (kubecontainer.ContainerID, error)

GetPodContainerID returns a container in the pod with the given ID.

func (*DockerManager) GetPodStatus

func (dm *DockerManager) GetPodStatus(uid types.UID, name, namespace string) (*kubecontainer.PodStatus, error)

GetPodStatus returns pod status

func (*DockerManager) ImageStats

func (dm *DockerManager) ImageStats() (*kubecontainer.ImageStats, error)

ImageStats is part of interface.

func (*DockerManager) InspectContainer

func (dm *DockerManager) InspectContainer(containerID string) (*cri.ContainerInspect, error)

InspectContainer is to inspect the container returning ContainerInspect object

func (*DockerManager) InspectImageByID

func (dm *DockerManager) InspectImageByID(imageID string) (*types.ImageInspect, error)

InspectImageByID checks if the inspected image matches what we are looking for

func (*DockerManager) IsImagePresent

func (dm *DockerManager) IsImagePresent(image kubecontainer.ImageSpec) (bool, error)

IsImagePresent checks whether the container image is already in the local storage

func (*DockerManager) KillPod

func (dm *DockerManager) KillPod(pod *v1.Pod, runningPod kubecontainer.Pod, gracePeriodOverride *int64) error

KillPod ends the pod

func (*DockerManager) ListContainers

func (dm *DockerManager) ListContainers() ([]*cri.Container, error)

ListContainers returns all containers list

func (*DockerManager) ListImages

func (dm *DockerManager) ListImages() ([]kubecontainer.Image, error)

ListImages gets all images currently on the machine

func (*DockerManager) PullImage

func (dm *DockerManager) PullImage(image kubecontainer.ImageSpec, pullSecrets []v1.Secret) (string, error)

PullImage pulls an image from network to local storage

func (*DockerManager) RemoveImage

func (dm *DockerManager) RemoveImage(image kubecontainer.ImageSpec) error

RemoveImage removes the specified image

func (*DockerManager) StartContainer

func (dm *DockerManager) StartContainer(containerID string) error

StartContainer is for ContainerStart

func (*DockerManager) Status

Status returns runtime status

func (*DockerManager) StopContainer

func (dm *DockerManager) StopContainer(containerID string, timeout uint32) error

StopContainer is to stop the container given its ID

func (*DockerManager) SyncPod

func (dm *DockerManager) SyncPod(pod *v1.Pod, apiPodStatus v1.PodStatus, podStatus *kubecontainer.PodStatus, pullSecrets []v1.Secret, backOff *flowcontrol.Backoff) kubecontainer.PodSyncResult

SyncPod is to synchronise pods

func (*DockerManager) Type

func (dm *DockerManager) Type() string

Type is string var to define typeof docker

func (*DockerManager) UpdatePodCIDR

func (dm *DockerManager) UpdatePodCIDR(podCIDR string) error

UpdatePodCIDR to update pod CIDR

func (*DockerManager) Version

func (dm *DockerManager) Version() (kubecontainer.Version, error)

Version returns kubecontainer version

type FakeDockerClient

type FakeDockerClient struct {
	dockerapi.CommonAPIClient
	// contains filtered or unexported fields
}

FakeDockerClient is object for a docker client

func NewFakeDockerClient

func NewFakeDockerClient(imageList map[string]types.ImageSummary) *FakeDockerClient

NewFakeDockerClient is to initialise docker client

func (*FakeDockerClient) ContainerCreate

func (cli *FakeDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)

ContainerCreate creates a container body and returns it

func (*FakeDockerClient) ContainerInspect

func (cli *FakeDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)

ContainerInspect returns container JSON to inspect

func (*FakeDockerClient) ContainerList

func (cli *FakeDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)

ContainerList returns list of created container

func (*FakeDockerClient) ContainerRemove

func (cli *FakeDockerClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error

ContainerRemove removes container object

func (*FakeDockerClient) ContainerStart

func (cli *FakeDockerClient) ContainerStart(ctx context.Context, containerID string, opts types.ContainerStartOptions) error

ContainerStart starts the container

func (*FakeDockerClient) ContainerStop

func (cli *FakeDockerClient) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error

ContainerStop stops the container

func (*FakeDockerClient) ImageList

func (cli *FakeDockerClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)

ImageList returns image list

func (*FakeDockerClient) ImagePull

func (cli *FakeDockerClient) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)

ImagePull reads image from repository

func (*FakeDockerClient) ImageRemove

func (cli *FakeDockerClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)

ImageRemove removes image from repository

func (*FakeDockerClient) ServerVersion

func (cli *FakeDockerClient) ServerVersion(ctx context.Context) (types.Version, error)

ServerVersion returns server version

type IFakeDockerClient

type IFakeDockerClient interface {
	ServerVersion(ctx context.Context) (types.Version, error)
}

IFakeDockerClient is interface for dockertools server version

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL