containerruntime

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDockerNative

func IsDockerNative() bool

IsDockerNative checks if docker is available in the PATH

func IsPodman

func IsPodman() bool

IsPodman checks if podman is available in the PATH

func ToUnixPath

func ToUnixPath(path string) string

ToUnixPath turns a windows path into a unix path

Types

type Container

type Container struct {
	Name             string
	Image            string
	Entrypoint       *string
	CommandShell     string
	Command          string
	WorkingDirectory string
	Volumes          []ContainerMount
	Environment      []EnvironmentProperty
	ContainerPorts   []ContainerPort
	Capabilities     []string
	User             string
	UserArgs         string
	Privileged       bool
	Interactive      bool
	TTY              bool
}

Container provides all methods to interact with the container runtime

func Create

func Create() Container

func (*Container) AddAllEnvironmentVariables

func (c *Container) AddAllEnvironmentVariables()

AddAllEnvironmentVariables adds all environment variables, but filters a few irrelevant ones (like PATH, HOME, etc.)

func (*Container) AddCacheMount

func (c *Container) AddCacheMount(name string, sourcePath string, targetPath string)

AddCacheMount adds a cache mount to the container

func (*Container) AddContainerPorts

func (c *Container) AddContainerPorts(ports []string)

AddContainerPorts adds multiple published ports

func (*Container) AddEnvironmentVariable

func (c *Container) AddEnvironmentVariable(name string, value string)

AddEnvironmentVariable adds a environment variable

func (*Container) AddEnvironmentVariables

func (c *Container) AddEnvironmentVariables(variables []string)

AddEnvironmentVariables adds multiple environment variables

func (*Container) AddVolume

func (c *Container) AddVolume(mount ContainerMount)

AddVolume mounts a directory into a container

func (*Container) AllowContainerRuntimeAcccess

func (c *Container) AllowContainerRuntimeAcccess()

AllowContainerRuntimeAcccess allows the container to access the container runtime

func (*Container) AutoTerminalParameters

func (c *Container) AutoTerminalParameters()

AutoTerminalParameters automatically sets the terminal parameters

func (*Container) DetectRuntime

func (c *Container) DetectRuntime() string

DetectRuntime returns the first available container runtime

func (*Container) GetDockerCommand

func (c *Container) GetDockerCommand() string

GetDockerCommand renders the command needed the run the container using docker

func (*Container) GetPodmanCommand

func (c *Container) GetPodmanCommand() string

GetPodmanCommand renders the command needed the run the container using podman

func (*Container) GetPullCommand

func (c *Container) GetPullCommand(runtime string) (string, error)

GetPullCommand gets the command to pull the required image

func (*Container) GetRunCommand

func (c *Container) GetRunCommand(runtime string) (string, error)

GetRunCommand gets the run command for the specified container runtime

func (*Container) PullImage

func (c *Container) PullImage() error

PullImage pulls the image for the container

func (*Container) StartContainer

func (c *Container) StartContainer() error

StartContainer starts the Container

type ContainerMount

type ContainerMount struct {
	MountType string
	Source    string
	Target    string
	Mode      MountMode
}

ContainerMount holds container volume mounts

type ContainerPort

type ContainerPort struct {
	Source int
	Target int
}

ContainerPort holds container ports

type EnvironmentProperty

type EnvironmentProperty struct {
	Name  string
	Value string
}

EnvironmentProperty holds environment variables

type MountMode

type MountMode string
const (
	WriteMode MountMode = "write"
	ReadMode  MountMode = "read"
)

Jump to

Keyboard shortcuts

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