docker

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	ID   string
	Port int
}

type DockerClient added in v0.0.5

type DockerClient interface {
	ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
	ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
	ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
	ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
	ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
	ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)
	Close() error
}

func NewDockerClient

func NewDockerClient() (DockerClient, error)

type DockerService added in v0.0.5

type DockerService struct {
	Client DockerClient
}

DockerService holds the client used to interact with Docker.

func NewDockerService added in v0.0.5

func NewDockerService(cli DockerClient) *DockerService

NewDockerService creates a new instance of DockerService with the given DockerClient.

func (*DockerService) FindContainer added in v0.0.5

func (ds *DockerService) FindContainer(imageName string) *Container

func (*DockerService) GetStatus added in v0.0.7

func (ds *DockerService) GetStatus() error

func (*DockerService) PullImage added in v0.0.5

func (ds *DockerService) PullImage(imageName string, registryConfig config.RegistryConfig) error

PullImage is a function that pulls a Docker image from a Docker registry. This is similar to running `docker pull <image>` from the command line.

func (*DockerService) RunContainer added in v0.0.5

func (ds *DockerService) RunContainer(imageName string, appCfg config.App) (*Container, error)

func (*DockerService) StopContainer added in v0.0.5

func (ds *DockerService) StopContainer(containerID string) error

func (*DockerService) StreamLogs added in v0.0.5

func (ds *DockerService) StreamLogs(container string, tail string) error

type ImagePullResponse

type ImagePullResponse struct {
	Status         string `json:"status"`
	ProgressDetail struct {
		Current int `json:"current"`
		Total   int `json:"total"`
	} `json:"progressDetail"`
	Progress string `json:"progress"`
	ID       string `json:"id"`
}

type MockDockerClient added in v0.0.5

type MockDockerClient struct {
	mock.Mock
}

func (*MockDockerClient) Close added in v0.0.5

func (m *MockDockerClient) Close() error

Close is a mock method to simulate closing the Docker client connection

func (*MockDockerClient) ContainerCreate added in v0.0.5

func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)

ContainerCreate mocks the ContainerCreate method

func (*MockDockerClient) ContainerInspect added in v0.0.5

func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)

ContainerInspect mocks the ContainerInspect method

func (*MockDockerClient) ContainerList added in v0.0.5

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

ContainerList mocks the ContainerList method

func (*MockDockerClient) ContainerLogs added in v0.0.5

func (m *MockDockerClient) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)

ContainerLogs mocks the ContainerLogs method

func (*MockDockerClient) ContainerRemove added in v0.0.7

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

ContainerRemove mocks the ContainerRemove method

func (*MockDockerClient) ContainerStart added in v0.0.5

func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error

ContainerStart mocks the ContainerStart method

func (*MockDockerClient) ContainerStop added in v0.0.5

func (m *MockDockerClient) ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error

ContainerStop mocks the ContainerStop method

func (*MockDockerClient) ImagePull added in v0.0.5

func (m *MockDockerClient) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)

ImagePull mocks the ImagePull method

Jump to

Keyboard shortcuts

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