docker

package
v0.0.0-...-b4f33a4 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	ContainerAPIClient
	ImageAPIClient
	NetworkAPIClient
}

APIClient is an interface that clients that talk with a docker server must implement.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an interface the must be implemented to provide Docker services through this package.

func NewDockerClient

func NewDockerClient(consoleOutput *console.Console, appDirectory string) (dockerClient *Client, err error)

func (*Client) ContainerExec

func (d *Client) ContainerExec(containerName string, rootUser bool, command []string) (ExecResult, error)

func (*Client) ContainerGetMounts

func (d *Client) ContainerGetMounts(containerName string) []types.MountPoint

ContainerGetMounts Returns a slice containing all the mounts to the given container.

func (*Client) ContainerList

func (d *Client) ContainerList(site string) ([]types.Container, error)

ContainerList Lists all running containers for a given site or all sites if no site is specified.

func (*Client) ContainerRestart

func (d *Client) ContainerRestart(containerName string) (bool, error)

func (*Client) ContainerRun

func (d *Client) ContainerRun(config *ContainerConfig, randomPorts, localUser bool) (id string, err error)

func (*Client) ContainerRunAndClean

func (d *Client) ContainerRunAndClean(config *ContainerConfig) (statusCode int64, body string, err error)

func (*Client) ContainerStop

func (d *Client) ContainerStop(containerName string) (bool, error)

func (*Client) EnsureNetwork

func (d *Client) EnsureNetwork(name string) (created bool, network types.NetworkResource, err error)

func (*Client) RemoveNetwork

func (d *Client) RemoveNetwork(name string) (removed bool, err error)

type ContainerAPIClient

type ContainerAPIClient interface {
	ContainerCreate(
		ctx context.Context,
		config *containerTypes.Config,
		hostConfig *containerTypes.HostConfig,
		networkingConfig *networkTypes.NetworkingConfig,
		platform *specs.Platform,
		containerName string) (containerTypes.CreateResponse, error)
	ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
	ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
	ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
	ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
	ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
	ContainerStart(ctx context.Context, container string, options types.ContainerStartOptions) error
	ContainerStop(ctx context.Context, name string, options containerTypes.StopOptions) error
	ContainerWait(
		ctx context.Context,
		container string,
		condition containerTypes.WaitCondition) (<-chan containerTypes.WaitResponse, <-chan error)
}

ContainerAPIClient defines API client methods for the containers.

type ContainerConfig

type ContainerConfig struct {
	Name        string
	Image       string
	Ports       []ExposedPorts
	HostName    string
	NetworkName string
	Volumes     []mount.Mount
	Command     []string
	Env         []string
	Labels      map[string]string
}

type Context

type Context struct {
	Current        bool   `json:"Current"`
	DockerEndpoint string `json:"DockerEndpoint"`
}

type ExecResult

type ExecResult struct {
	StdOut   string
	StdErr   string
	ExitCode int
}

type ExposedPorts

type ExposedPorts struct {
	Port     string
	Protocol string
}

type ImageAPIClient

type ImageAPIClient interface {
	ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)
	ImageRemove(ctx context.Context, image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
	ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
}

ImageAPIClient defines API client methods for the images.

type NetworkAPIClient

type NetworkAPIClient interface {
	NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
	NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
	NetworkRemove(ctx context.Context, network string) error
}

NetworkAPIClient defines API client methods for the networks.

type ViperClient

type ViperClient interface {
	SetConfigName(in string)
	SetConfigType(in string)
	AddConfigPath(in string)
	ReadInConfig() error
	SafeWriteConfig() error
	GetTime(key string) time.Time
	Set(key string, value interface{})
	WriteConfig() error
}

ViperClient defines a mock Viper client for testing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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