environment

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ContainerRuntimeKey is the settings key for container runtime.
	ContainerRuntimeKey = "runtime"
)

VM configurations

Variables

This section is empty.

Functions

func ContainerRuntimes

func ContainerRuntimes() (names []string)

ContainerRuntimes return the names of available container runtimes.

func RegisterContainer

func RegisterContainer(name string, f NewContainerFunc, hidden bool)

RegisterContainer registers a new container runtime. If hidden is true, the container is not displayed as an available runtime.

Types

type Arch added in v0.3.0

type Arch string

Arch is the CPU architecture of the VM.

const (
	X8664   Arch = "x86_64"
	AARCH64 Arch = "aarch64"
)

func HostArch added in v0.4.0

func HostArch() Arch

HostArch returns the host CPU architecture.

func (Arch) GoArch added in v0.3.0

func (a Arch) GoArch() string

GoArch returns the GOARCH equivalent value for the architecture.

func (Arch) Value added in v0.3.0

func (a Arch) Value() Arch

Value converts the underlying architecture alias value to one of X8664 or AARCH64.

type Container

type Container interface {
	// Name is the name of the container runtime. e.g. docker, containerd
	Name() string
	// Provision provisions/installs the container runtime.
	// Should be idempotent.
	Provision(ctx context.Context) error
	// Start starts the container runtime.
	Start(ctx context.Context) error
	// Stop stops the container runtime.
	Stop(ctx context.Context) error
	// Teardown tears down/uninstall the container runtime.
	Teardown(ctx context.Context) error
	// Version returns the container runtime version.
	Version(ctx context.Context) string
	// Running returns if the container runtime is currently running.
	Running(ctx context.Context) bool

	Dependencies
}

Container is container environment.

func NewContainer

func NewContainer(runtime string, host HostActions, guest GuestActions) (Container, error)

NewContainer creates a new container environment.

type Dependencies

type Dependencies interface {
	// Dependencies are dependencies that must exist on the host.
	// TODO this may need to accommodate non-brew installable dependencies
	Dependencies() []string
}

Dependencies are dependencies that must exist on the host.

type GuestActions

type GuestActions interface {

	// Start starts up the VM
	Start(ctx context.Context, conf config.Config) error
	// Stop shuts down the VM
	Stop(ctx context.Context, force bool) error
	// Restart restarts the VM
	Restart(ctx context.Context) error
	// SSH performs an ssh connection to the VM
	SSH(workingDir string, args ...string) error
	// Created returns if the VM has been previously created.
	Created() bool
	// Running returns if the VM is currently running.
	Running(ctx context.Context) bool
	// Env retrieves environment variable in the VM.
	Env(string) (string, error)
	// Get retrieves a configuration in the VM.
	Get(key string) string
	// Set sets configuration in the VM.
	Set(key, value string) error
	// User returns the username of the user in the VM.
	User() (string, error)
	// Arch returns the architecture of the VM.
	Arch() Arch
	// contains filtered or unexported methods
}

GuestActions are actions performed on the guest i.e. VM.

type Host

type Host interface {
	HostActions
}

Host is the host environment.

type HostActions

type HostActions interface {

	// WithEnv creates a new instance based on the current instance
	// with the specified environment variables.
	WithEnv(env ...string) HostActions
	// WithDir creates a new instance based on the current instance
	// with the working directory set to dir.
	WithDir(dir string) HostActions
	// Env retrieves environment variable on the host.
	Env(string) string
	// contains filtered or unexported methods
}

HostActions are actions performed on the host.

type NewContainerFunc

type NewContainerFunc func(host HostActions, guest GuestActions) Container

NewContainerFunc is implemented by container runtime implementations to create a new instance.

type VM

type VM interface {
	GuestActions
	Dependencies
	Host() HostActions
	Teardown(ctx context.Context) error
}

VM is virtual machine.

Directories

Path Synopsis
container
vm

Jump to

Keyboard shortcuts

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