container

package
v0.2.58 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 59 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDockerClient added in v0.2.9

func GetDockerClient(ctx context.Context) (cli client.APIClient, err error)

func GetHostInfo added in v0.2.26

func GetHostInfo(ctx context.Context) (info types.Info, err error)

func ImageExistsLocally

func ImageExistsLocally(ctx context.Context, imageName string, platform string) (bool, error)

ImageExistsLocally returns a boolean indicating if an image with the requested name, tag and architecture exists in the local docker image store

func LoadDockerAuthConfig added in v0.2.26

func LoadDockerAuthConfig(ctx context.Context, image string) (registry.AuthConfig, error)

func LoadDockerAuthConfigs added in v0.2.36

func LoadDockerAuthConfigs(ctx context.Context) map[string]registry.AuthConfig

func NewDockerBuildExecutor

func NewDockerBuildExecutor(input NewDockerBuildExecutorInput) common.Executor

NewDockerBuildExecutor function to create a run executor for the container

func NewDockerNetworkCreateExecutor added in v0.2.53

func NewDockerNetworkCreateExecutor(name string) common.Executor

func NewDockerNetworkRemoveExecutor added in v0.2.53

func NewDockerNetworkRemoveExecutor(name string) common.Executor

func NewDockerPullExecutor

func NewDockerPullExecutor(input NewDockerPullExecutorInput) common.Executor

NewDockerPullExecutor function to create a run executor for the container

func NewDockerVolumeRemoveExecutor added in v0.2.2

func NewDockerVolumeRemoveExecutor(volumeName string, force bool) common.Executor

func RemoveImage added in v0.2.22

func RemoveImage(ctx context.Context, imageName string, force bool, pruneChildren bool) (bool, error)

RemoveImage removes image from local store, the function is used to run different container image architectures

func RunnerArch added in v0.2.31

func RunnerArch(ctx context.Context) string

Arch fetches values from docker info and translates architecture to GitHub actions compatible runner.arch values https://github.com/github/docs/blob/main/data/reusables/actions/runner-arch-description.md

Types

type Container added in v0.2.2

type Container interface {
	Create(capAdd []string, capDrop []string) common.Executor
	Copy(destPath string, files ...*FileEntry) common.Executor
	CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error
	CopyDir(destPath string, srcPath string, useGitIgnore bool) common.Executor
	GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error)
	Pull(forcePull bool) common.Executor
	Start(attach bool) common.Executor
	Exec(command []string, env map[string]string, user, workdir string) common.Executor
	UpdateFromEnv(srcPath string, env *map[string]string) common.Executor
	UpdateFromImageEnv(env *map[string]string) common.Executor
	Remove() common.Executor
	Close() common.Executor
	ReplaceLogWriter(io.Writer, io.Writer) (io.Writer, io.Writer)
}

Container for managing docker run containers

type ExecutionsEnvironment added in v0.2.34

type ExecutionsEnvironment interface {
	Container
	ToContainerPath(string) string
	GetActPath() string
	GetPathVariableName() string
	DefaultPathVariable() string
	JoinPathVariable(...string) string
	GetRunnerContext(ctx context.Context) map[string]interface{}
	// On windows PATH and Path are the same key
	IsEnvironmentCaseInsensitive() bool
}

func NewContainer added in v0.2.2

func NewContainer(input *NewContainerInput) ExecutionsEnvironment

NewContainer creates a reference to a container

type FileEntry added in v0.2.2

type FileEntry struct {
	Name string
	Mode int64
	Body string
}

FileEntry is a file to copy to a container

type HostEnvironment added in v0.2.34

type HostEnvironment struct {
	Path      string
	TmpDir    string
	ToolCache string
	Workdir   string
	ActPath   string
	CleanUp   func()
	StdOut    io.Writer
}

func (*HostEnvironment) Close added in v0.2.34

func (e *HostEnvironment) Close() common.Executor

func (*HostEnvironment) Copy added in v0.2.34

func (e *HostEnvironment) Copy(destPath string, files ...*FileEntry) common.Executor

func (*HostEnvironment) CopyDir added in v0.2.34

func (e *HostEnvironment) CopyDir(destPath string, srcPath string, useGitIgnore bool) common.Executor

func (*HostEnvironment) CopyTarStream added in v0.2.50

func (e *HostEnvironment) CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error

func (*HostEnvironment) Create added in v0.2.34

func (e *HostEnvironment) Create(_ []string, _ []string) common.Executor

func (*HostEnvironment) DefaultPathVariable added in v0.2.34

func (e *HostEnvironment) DefaultPathVariable() string

func (*HostEnvironment) Exec added in v0.2.34

func (e *HostEnvironment) Exec(command []string, env map[string]string, user, workdir string) common.Executor

func (*HostEnvironment) ExecWithCmdLine added in v0.2.50

func (e *HostEnvironment) ExecWithCmdLine(command []string, cmdline string, env map[string]string, user, workdir string) common.Executor

func (*HostEnvironment) GetActPath added in v0.2.34

func (e *HostEnvironment) GetActPath() string

func (*HostEnvironment) GetContainerArchive added in v0.2.34

func (e *HostEnvironment) GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error)

func (*HostEnvironment) GetPathVariableName added in v0.2.34

func (*HostEnvironment) GetPathVariableName() string

func (*HostEnvironment) GetRunnerContext added in v0.2.34

func (e *HostEnvironment) GetRunnerContext(_ context.Context) map[string]interface{}

func (*HostEnvironment) IsEnvironmentCaseInsensitive added in v0.2.45

func (*HostEnvironment) IsEnvironmentCaseInsensitive() bool

func (*HostEnvironment) JoinPathVariable added in v0.2.34

func (*HostEnvironment) JoinPathVariable(paths ...string) string

func (*HostEnvironment) Pull added in v0.2.34

func (e *HostEnvironment) Pull(_ bool) common.Executor

func (*HostEnvironment) Remove added in v0.2.34

func (e *HostEnvironment) Remove() common.Executor

func (*HostEnvironment) ReplaceLogWriter added in v0.2.34

func (e *HostEnvironment) ReplaceLogWriter(stdout io.Writer, _ io.Writer) (io.Writer, io.Writer)

func (*HostEnvironment) Start added in v0.2.34

func (e *HostEnvironment) Start(_ bool) common.Executor

func (*HostEnvironment) ToContainerPath added in v0.2.34

func (e *HostEnvironment) ToContainerPath(path string) string

func (*HostEnvironment) UpdateFromEnv added in v0.2.34

func (e *HostEnvironment) UpdateFromEnv(srcPath string, env *map[string]string) common.Executor

func (*HostEnvironment) UpdateFromImageEnv added in v0.2.34

func (e *HostEnvironment) UpdateFromImageEnv(_ *map[string]string) common.Executor

type LinuxContainerEnvironmentExtensions added in v0.2.34

type LinuxContainerEnvironmentExtensions struct {
}

func (*LinuxContainerEnvironmentExtensions) DefaultPathVariable added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) DefaultPathVariable() string

func (*LinuxContainerEnvironmentExtensions) GetActPath added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) GetPathVariableName added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) GetPathVariableName() string

func (*LinuxContainerEnvironmentExtensions) GetRunnerContext added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) GetRunnerContext(ctx context.Context) map[string]interface{}

func (*LinuxContainerEnvironmentExtensions) IsEnvironmentCaseInsensitive added in v0.2.45

func (*LinuxContainerEnvironmentExtensions) IsEnvironmentCaseInsensitive() bool

func (*LinuxContainerEnvironmentExtensions) JoinPathVariable added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) JoinPathVariable(paths ...string) string

func (*LinuxContainerEnvironmentExtensions) ToContainerPath added in v0.2.34

func (*LinuxContainerEnvironmentExtensions) ToContainerPath(path string) string

Resolves the equivalent host path inside the container This is required for windows and WSL 2 to translate things like C:\Users\Myproject to /mnt/users/Myproject For use in docker volumes and binds

type NewContainerInput added in v0.2.2

type NewContainerInput struct {
	Image          string
	Username       string
	Password       string
	Entrypoint     []string
	Cmd            []string
	WorkingDir     string
	Env            []string
	Binds          []string
	Mounts         map[string]string
	Name           string
	Stdout         io.Writer
	Stderr         io.Writer
	NetworkMode    string
	Privileged     bool
	UsernsMode     string
	Platform       string
	Options        string
	NetworkAliases []string
	ExposedPorts   nat.PortSet
	PortBindings   nat.PortMap
}

NewContainerInput the input for the New function

type NewDockerBuildExecutorInput

type NewDockerBuildExecutorInput struct {
	ContextDir   string
	Dockerfile   string
	BuildContext io.Reader
	ImageTag     string
	Platform     string
}

NewDockerBuildExecutorInput the input for the NewDockerBuildExecutor function

type NewDockerPullExecutorInput

type NewDockerPullExecutorInput struct {
	Image     string
	ForcePull bool
	Platform  string
	Username  string
	Password  string
}

NewDockerPullExecutorInput the input for the NewDockerPullExecutor function

Jump to

Keyboard shortcuts

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