dockerengine

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package dockerengine provides functionality to interact with the Docker server.

Package dockerengine is a generated GoMock package.

Index

Constants

View Source
const (
	OSLinux   = "linux"
	OSWindows = "windows"

	ArchAMD64 = "amd64"
	ArchX86   = "x86_64"
	ArchARM   = "arm"
	ArchARM64 = "arm64"
)

Operating systems and architectures supported by docker.

Variables

View Source
var ErrDockerCommandNotFound = errors.New("docker: command not found")

ErrDockerCommandNotFound means the docker command is not found.

Functions

func PlatformString added in v1.12.0

func PlatformString(os, arch string) string

PlatformString returns a specified of the format <os>/<arch>.

Types

type BuildArguments

type BuildArguments struct {
	URI        string            // Required. Location of ECR Repo. Used to generate image name in conjunction with tag.
	Tags       []string          // Required. List of tags to apply to the image.
	Dockerfile string            // Required. Dockerfile to pass to `docker build` via --file flag.
	Context    string            // Optional. Build context directory to pass to `docker build`.
	Target     string            // Optional. The target build stage to pass to `docker build`.
	CacheFrom  []string          // Optional. Images to consider as cache sources to pass to `docker build`
	Platform   string            // Optional. OS/Arch to pass to `docker build`.
	Args       map[string]string // Optional. Build args to pass via `--build-arg` flags. Equivalent to ARG directives in dockerfile.
	Labels     map[string]string // Required. Set metadata for an image.
}

BuildArguments holds the arguments that can be passed while building a container.

func (*BuildArguments) GenerateDockerBuildArgs added in v1.28.0

func (in *BuildArguments) GenerateDockerBuildArgs(c DockerCmdClient) ([]string, error)

GenerateDockerBuildArgs returns command line arguments to be passed to the Docker build command based on the provided BuildArguments. Returns an error if no tags are provided for building an image.

type Cmd

type Cmd interface {
	Run(name string, args []string, options ...exec.CmdOption) error
	RunWithContext(ctx context.Context, name string, args []string, opts ...exec.CmdOption) error
}

Cmd is the interface implemented by external commands.

type DockerCmdClient added in v1.28.0

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

DockerCmdClient represents the docker client to interact with the server via external commands.

func New

func New(cmd Cmd) DockerCmdClient

New returns CmdClient to make requests against the Docker daemon via external commands.

func (DockerCmdClient) Build added in v1.28.0

Build will run a `docker build` command for the given ecr repo URI and build arguments.

func (DockerCmdClient) CheckDockerEngineRunning added in v1.28.0

func (c DockerCmdClient) CheckDockerEngineRunning() error

CheckDockerEngineRunning will run `docker info` command to check if the docker engine is running.

func (DockerCmdClient) GetPlatform added in v1.28.0

func (c DockerCmdClient) GetPlatform() (os, arch string, err error)

GetPlatform will run the `docker version` command to get the OS/Arch.

func (DockerCmdClient) IsContainerRunning added in v1.30.0

func (c DockerCmdClient) IsContainerRunning(containerName string) (bool, error)

IsContainerRunning checks if a specific Docker container is running.

func (DockerCmdClient) IsEcrCredentialHelperEnabled added in v1.28.0

func (c DockerCmdClient) IsEcrCredentialHelperEnabled(uri string) bool

IsEcrCredentialHelperEnabled return true if ecr-login is enabled either globally or registry level

func (DockerCmdClient) Login added in v1.28.0

func (c DockerCmdClient) Login(uri, username, password string) error

Login will run a `docker login` command against the Service repository URI with the input uri and auth data.

func (DockerCmdClient) Push added in v1.28.0

func (c DockerCmdClient) Push(ctx context.Context, uri string, w io.Writer, tags ...string) (digest string, err error)

Push pushes the images with the specified tags and ecr repository URI, and returns the image digest on success.

func (DockerCmdClient) Rm added in v1.30.0

func (c DockerCmdClient) Rm(containerID string) error

Rm calls `docker rm` to remove a stopped container.

func (DockerCmdClient) Run added in v1.30.0

func (c DockerCmdClient) Run(ctx context.Context, options *RunOptions) error

Run runs a Docker container with the sepcified options.

func (DockerCmdClient) Stop added in v1.30.0

func (c DockerCmdClient) Stop(containerID string) error

Stop calls `docker stop` to stop a running container.

type ErrDockerDaemonNotResponsive

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

ErrDockerDaemonNotResponsive means the docker daemon is not responsive.

func (ErrDockerDaemonNotResponsive) Error

type MockCmd

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

MockCmd is a mock of Cmd interface.

func NewMockCmd

func NewMockCmd(ctrl *gomock.Controller) *MockCmd

NewMockCmd creates a new mock instance.

func (*MockCmd) EXPECT

func (m *MockCmd) EXPECT() *MockCmdMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCmd) Run

func (m *MockCmd) Run(name string, args []string, options ...exec.CmdOption) error

Run mocks base method.

func (*MockCmd) RunWithContext added in v1.28.0

func (m *MockCmd) RunWithContext(ctx context.Context, name string, args []string, opts ...exec.CmdOption) error

RunWithContext mocks base method.

type MockCmdMockRecorder

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

MockCmdMockRecorder is the mock recorder for MockCmd.

func (*MockCmdMockRecorder) Run

func (mr *MockCmdMockRecorder) Run(name, args interface{}, options ...interface{}) *gomock.Call

Run indicates an expected call of Run.

func (*MockCmdMockRecorder) RunWithContext added in v1.28.0

func (mr *MockCmdMockRecorder) RunWithContext(ctx, name, args interface{}, opts ...interface{}) *gomock.Call

RunWithContext indicates an expected call of RunWithContext.

type RunLogOptions added in v1.30.0

type RunLogOptions struct {
	Color      *color.Color
	Output     io.Writer
	LinePrefix string
}

RunLogOptions holds the logging configuration for Run().

type RunOptions added in v1.30.0

type RunOptions struct {
	ImageURI         string            // Required. The image name to run.
	Secrets          map[string]string // Optional. Secrets to pass to the container as environment variables.
	EnvVars          map[string]string // Optional. Environment variables to pass to the container.
	ContainerName    string            // Optional. The name for the container.
	ContainerPorts   map[string]string // Optional. Contains host and container ports.
	Command          []string          // Optional. The command to run in the container.
	ContainerNetwork string            // Optional. Network mode for the container.
	LogOptions       RunLogOptions
}

RunOptions holds the options for running a Docker container.

Jump to

Keyboard shortcuts

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