tools

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyEnv

func ApplyEnv(env map[string]string) func(string, ...string) error

ApplyEnv makes environment variable application a distinct step.

func GoTimeoutFlag

func GoTimeoutFlag(ctx context.Context) []string

GoTimeoutFlag returns a timeout flag and duration corresponding to the given context deadline as a slice of strings. If the context has no deadline then an empty slice of strings is returned.

func GoVerboseFlag

func GoVerboseFlag() []string

GoVerboseFlag checks if 'Mage' was run with the verbose flag and if so returns the Go verbose flag '-v' as a slice of strings. An empty slice of strings is returned otherwise.

func Runtime

func Runtime() (string, bool)

Runtime attempts to find an available container runtime in the PATH. The path to the first available runtime is returned along with a boolean value indicating if any runtimes were found.

Types

type BuildCommand

type BuildCommand struct {
	io.Writer
	// contains filtered or unexported fields
}

BuildCommand is used to generate a command which will build a container image.

type BuildOption

type BuildOption func(c *BuildCommand) error

func BuildArgs

func BuildArgs(args ...string) BuildOption

BuildArgs applies build arguments for variable substitution within a container file.

func BuildContainerFilePath

func BuildContainerFilePath(path string) BuildOption

BuildContainerFilepath is a path to a container file containing build instructions.

func BuildEnv

func BuildEnv(env map[string]string) BuildOption

BuildEnv adds the supplied map of variable/value pairs to the commands run environment.

func BuildRuntime

func BuildRuntime(runtime string) BuildOption

BuildRuntime manually sets the desired container runtime.

func BuildTags

func BuildTags(tags ...string) BuildOption

BuildTags applies tags to the build image.

type Command

type Command func(...string) error

func NewBuildCommand

func NewBuildCommand(contextDirectory string, options ...BuildOption) (Command, error)

contextDirectory is the "build" directory from which the container runtime will observe as the relative root location. options is a variadic slice of additional options to apply to the container build command. An error will be returned if any invalid parameters are supplied or there is no available container runtime on the system.

func NewRunCommand

func NewRunCommand(image string, options ...RunOption) (Command, error)

NewRunCommand returns a function which will run a container with optional arguments.

image is a mandatory image name for the container to run in. options is a variadic slice of additional options to apply to the container run command. An error will be returned if any invalid parameters are supplied or there is no available container runtime on the system.

type ContainerError

type ContainerError string

func (ContainerError) Error

func (e ContainerError) Error() string

type Mount

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

Mount abstracts a volume mount used with container commands.

func NewMount

func NewMount(options ...MountOption) (Mount, error)

NewMount returns a mount with the supplied options applied. An error is returned if any of the options are invalid.

func (*Mount) Options

func (m *Mount) Options(options ...MountOption) error

Options applies the given options to a mount. If any options are invalid an error is returned.

func (*Mount) String

func (m *Mount) String() string

type MountOption

type MountOption func(m *Mount) error
var MountReadOnly MountOption = func(m *Mount) error {
	m.readOnly = true

	return nil
}

MountReadOnly sets the mount to be "readonly" within the container.

func MountSource

func MountSource(source string) MountOption

MountSource sets the mount source location. The nature of this value changes with the mount type.

func MountTarget

func MountTarget(target string) MountOption

MountTarget sets the mount target within the container.

func MountType

func MountType(mountType string) MountOption

MountType sets the mount type.

type RunCommand

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

RunCommand wraps a command which runs a container.

type RunOption

type RunOption func(*RunCommand) error
var RunDisableSELinux RunOption = func(c *RunCommand) error {
	c.disableSELinux = true

	return nil
}

RunDisableSELinux sets "--security-opt label=disable" to bypass setting a container policy.

var RunRemoveAfter RunOption = func(c *RunCommand) error {
	c.removeAfter = true

	return nil
}

RunRemoveAfter ensures the container is removed after it exits.

func RunEnv

func RunEnv(env map[string]string) RunOption

RunEnv adds the supplied map of variable/value pairs to the commands run environment.

func RunMounts

func RunMounts(mounts ...Mount) RunOption

RunMounts adds the supplied mounts to the container when run.

func RunOut

func RunOut(out io.Writer) RunOption

Out redirects output from the run command to the supplied io.Writer.

func RunRuntime

func RunRuntime(runtime string) RunOption

RunRuntime manually sets the desired container runtime.

func RunWorkingDir

func RunWorkingDir(workingDir string) RunOption

RunWorkingDir sets a working directory within the container.

Jump to

Keyboard shortcuts

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