kubernetes: github.com/igm/kubernetes/pkg/kubelet/dockertools Index | Files

package dockertools

import "github.com/igm/kubernetes/pkg/kubelet/dockertools"

Index

Package Files

docker.go fake_docker_client.go

Variables

var (
    // ErrNoContainersInPod is returned when there are no containers for a given pod
    ErrNoContainersInPod = errors.New("no containers exist for this pod")

    // ErrNoNetworkContainerInPod is returned when there is no network container for a given pod
    ErrNoNetworkContainerInPod = errors.New("No network container exists for this pod")

    // ErrContainerCannotRun is returned when a container is created, but cannot run properly
    ErrContainerCannotRun = errors.New("Container cannot run")
)

func BuildDockerName Uses

func BuildDockerName(manifestUUID, podFullName string, container *api.Container) string

Creates a name which can be reversed to identify both full pod name and container name.

func GetDockerPodInfo Uses

func GetDockerPodInfo(client DockerInterface, manifest api.PodSpec, podFullName, uuid string) (api.PodInfo, error)

GetDockerPodInfo returns docker info for all containers in the pod/manifest.

func GetKubeletDockerContainerLogs Uses

func GetKubeletDockerContainerLogs(client DockerInterface, containerID, tail string, follow bool, stdout, stderr io.Writer) (err error)

GetKubeletDockerContainerLogs returns logs of specific container By default the function will return snapshot of the container log Log streaming is possible if 'follow' param is set to true Log tailing is possible when number of tailed lines are set and only if 'follow' is false TODO: Make 'RawTerminal' option flagable.

func GetRecentDockerContainersWithNameAndUUID Uses

func GetRecentDockerContainersWithNameAndUUID(client DockerInterface, podFullName, uuid, containerName string) ([]*docker.Container, error)

GetRecentDockerContainersWithNameAndUUID returns a list of dead docker containers which matches the name and uuid given.

func HashContainer Uses

func HashContainer(container *api.Container) uint64

func ParseDockerName Uses

func ParseDockerName(name string) (podFullName, uuid, containerName string, hash uint64)

Unpacks a container name, returning the pod full name and container name we would have used to construct the docker name. If the docker name isn't the one we created, we may return empty strings.

func RequireLatestImage Uses

func RequireLatestImage(name string) bool

RequireLatestImage returns if the user wants the latest image

type ContainerCommandRunner Uses

type ContainerCommandRunner interface {
    RunInContainer(containerID string, cmd []string) ([]byte, error)
}

func NewDockerContainerCommandRunner Uses

func NewDockerContainerCommandRunner(client DockerInterface) ContainerCommandRunner

NewDockerContainerCommandRunner creates a ContainerCommandRunner which uses nsinit to run a command inside a container.

type DockerContainers Uses

type DockerContainers map[DockerID]*docker.APIContainers

DockerContainers is a map of containers

func GetKubeletDockerContainers Uses

func GetKubeletDockerContainers(client DockerInterface, allContainers bool) (DockerContainers, error)

GetKubeletDockerContainers takes client and boolean whether to list all container or just the running ones. Returns a map of docker containers that we manage. The map key is the docker container ID

func (DockerContainers) FindContainersByPodFullName Uses

func (c DockerContainers) FindContainersByPodFullName(podFullName string) map[string]*docker.APIContainers

Note, this might return containers belong to a different Pod instance with the same name

func (DockerContainers) FindPodContainer Uses

func (c DockerContainers) FindPodContainer(podFullName, uuid, containerName string) (*docker.APIContainers, bool, uint64)

type DockerID Uses

type DockerID string

DockerID is an ID of docker container. It is a type to make it clear when we're working with docker container Ids

type DockerInterface Uses

type DockerInterface interface {
    ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)
    InspectContainer(id string) (*docker.Container, error)
    CreateContainer(docker.CreateContainerOptions) (*docker.Container, error)
    StartContainer(id string, hostConfig *docker.HostConfig) error
    StopContainer(id string, timeout uint) error
    RemoveContainer(opts docker.RemoveContainerOptions) error
    InspectImage(image string) (*docker.Image, error)
    PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error
    Logs(opts docker.LogsOptions) error
    Version() (*docker.Env, error)
    CreateExec(docker.CreateExecOptions) (*docker.Exec, error)
    StartExec(string, docker.StartExecOptions) error
}

DockerInterface is an abstract interface for testability. It abstracts the interface of docker.Client.

type DockerPuller Uses

type DockerPuller interface {
    Pull(image string) error
    IsImagePresent(image string) (bool, error)
}

DockerPuller is an abstract interface for testability. It abstracts image pull operations.

func NewDockerPuller Uses

func NewDockerPuller(client DockerInterface, qps float32, burst int) DockerPuller

NewDockerPuller creates a new instance of the default implementation of DockerPuller.

type FakeDockerClient Uses

type FakeDockerClient struct {
    sync.Mutex
    ContainerList []docker.APIContainers
    Container     *docker.Container
    ContainerMap  map[string]*docker.Container
    Image         *docker.Image
    Err           error

    Stopped []string

    Created     []string
    Removed     []string
    VersionInfo docker.Env
    // contains filtered or unexported fields
}

FakeDockerClient is a simple fake docker client, so that kubelet can be run for testing without requiring a real docker setup.

func (*FakeDockerClient) AssertCalls Uses

func (f *FakeDockerClient) AssertCalls(calls []string) (err error)

func (*FakeDockerClient) CreateContainer Uses

func (f *FakeDockerClient) CreateContainer(c docker.CreateContainerOptions) (*docker.Container, error)

CreateContainer is a test-spy implementation of DockerInterface.CreateContainer. It adds an entry "create" to the internal method call record.

func (*FakeDockerClient) CreateExec Uses

func (f *FakeDockerClient) CreateExec(_ docker.CreateExecOptions) (*docker.Exec, error)

func (*FakeDockerClient) InspectContainer Uses

func (f *FakeDockerClient) InspectContainer(id string) (*docker.Container, error)

InspectContainer is a test-spy implementation of DockerInterface.InspectContainer. It adds an entry "inspect" to the internal method call record.

func (*FakeDockerClient) InspectImage Uses

func (f *FakeDockerClient) InspectImage(name string) (*docker.Image, error)

InspectImage is a test-spy implementation of DockerInterface.InspectImage. It adds an entry "inspect" to the internal method call record.

func (*FakeDockerClient) ListContainers Uses

func (f *FakeDockerClient) ListContainers(options docker.ListContainersOptions) ([]docker.APIContainers, error)

ListContainers is a test-spy implementation of DockerInterface.ListContainers. It adds an entry "list" to the internal method call record.

func (*FakeDockerClient) Logs Uses

func (f *FakeDockerClient) Logs(opts docker.LogsOptions) error

Logs is a test-spy implementation of DockerInterface.Logs. It adds an entry "logs" to the internal method call record.

func (*FakeDockerClient) PullImage Uses

func (f *FakeDockerClient) PullImage(opts docker.PullImageOptions, auth docker.AuthConfiguration) error

PullImage is a test-spy implementation of DockerInterface.StopContainer. It adds an entry "pull" to the internal method call record.

func (*FakeDockerClient) RemoveContainer Uses

func (f *FakeDockerClient) RemoveContainer(opts docker.RemoveContainerOptions) error

func (*FakeDockerClient) StartContainer Uses

func (f *FakeDockerClient) StartContainer(id string, hostConfig *docker.HostConfig) error

StartContainer is a test-spy implementation of DockerInterface.StartContainer. It adds an entry "start" to the internal method call record.

func (*FakeDockerClient) StartExec Uses

func (f *FakeDockerClient) StartExec(_ string, _ docker.StartExecOptions) error

func (*FakeDockerClient) StopContainer Uses

func (f *FakeDockerClient) StopContainer(id string, timeout uint) error

StopContainer is a test-spy implementation of DockerInterface.StopContainer. It adds an entry "stop" to the internal method call record.

func (*FakeDockerClient) Version Uses

func (f *FakeDockerClient) Version() (*docker.Env, error)

type FakeDockerPuller Uses

type FakeDockerPuller struct {
    sync.Mutex

    HasImages    []string
    ImagesPulled []string

    // Every pull will return the first error here, and then reslice
    // to remove it. Will give nil errors if this slice is empty.
    ErrorsToInject []error
}

FakeDockerPuller is a stub implementation of DockerPuller.

func (*FakeDockerPuller) IsImagePresent Uses

func (f *FakeDockerPuller) IsImagePresent(name string) (bool, error)

func (*FakeDockerPuller) Pull Uses

func (f *FakeDockerPuller) Pull(image string) (err error)

Pull records the image pull attempt, and optionally injects an error.

Package dockertools imports 18 packages (graph). Updated 2018-04-09. Refresh now. Tools for package owners.