runtime

package
v0.57.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotFound = "NotFound"
	Running  = "Running"
	Stopped  = "Stopped"
)

Variables

View Source
var ContainerRuntimes = map[string]Initializer{}

Functions

func Register added in v0.15.0

func Register(name string, initFn Initializer)

func WaitForContainerRunning added in v0.33.0

func WaitForContainerRunning(ctx context.Context, r ContainerRuntime, contName, nodeName string) error

WaitForContainerRunning waits for container to become running by polling its status.

Types

type ContainerMount added in v0.35.0

type ContainerMount struct {
	Source      string
	Destination string
}

type ContainerRuntime

type ContainerRuntime interface {
	// Initializes the Container runtime struct
	Init(...RuntimeOption) error
	// Mgmt return management network configuration of a runtime
	Mgmt() *types.MgmtNet
	// Adds custom configuration items to the container runtime struct
	WithConfig(*RuntimeConfig)
	// Set the network management details (generated by the config.go)
	WithMgmtNet(*types.MgmtNet)
	// Instructs the runtime not to delete the mgmt network on destroy
	WithKeepMgmtNet()
	// Create container (bridge) network
	CreateNet(context.Context) error
	// Delete container (bridge) network
	DeleteNet(context.Context) error
	// Pull container image if not present
	PullImage(context.Context, string, types.PullPolicyValue) error
	// CreateContainer creates a container, but does not start it
	CreateContainer(context.Context, *types.NodeConfig) (string, error)
	// Start pre-created container by its name. Returns an extra interface that can be used to receive signals
	// about the container life-cycle after it was created, e.g. for post-deploy tasks
	StartContainer(context.Context, string, Node) (interface{}, error)
	// Stop running container by its name
	StopContainer(context.Context, string) error
	// Pause a container identified by its name
	PauseContainer(context.Context, string) error
	// UnPause / resume a container identified by its name
	UnpauseContainer(context.Context, string) error
	// List all containers matching labels
	ListContainers(context.Context, []*types.GenericFilter) ([]GenericContainer, error)
	// Get a netns path using the name of a container
	GetNSPath(context.Context, string) (string, error)
	// Executes cmd on container identified with id and returns stdout, stderr bytes and an error
	Exec(ctx context.Context, cID string, execCmd *exec.ExecCmd) (*exec.ExecResult, error)
	// ExecNotWait executes cmd on container identified with id but doesn't wait for output nor attaches stdout/err
	ExecNotWait(ctx context.Context, cID string, execCmd *exec.ExecCmd) error
	// Delete container by its name
	DeleteContainer(context.Context, string) error
	// Getter for runtime config options
	Config() RuntimeConfig
	GetName() string
	// GetHostsPath returns fs path to a file which is mounted as /etc/hosts into a given container
	GetHostsPath(context.Context, string) (string, error)
	// GetContainerStatus retrieves the ContainerStatus of the named container
	GetContainerStatus(ctx context.Context, cID string) ContainerStatus
	// IsHealthy returns true is the container is reported as being healthy, false otherwise
	IsHealthy(ctx context.Context, cID string) (bool, error)
}

type ContainerStatus added in v0.32.0

type ContainerStatus string

type GenericContainer added in v0.35.0

type GenericContainer struct {
	Names           []string
	ID              string
	ShortID         string // trimmed ID for display purposes
	Image           string
	State           string
	Status          string
	Labels          map[string]string
	Pid             int
	NetworkSettings GenericMgmtIPs
	Mounts          []ContainerMount

	Ports []*types.GenericPortBinding
	// contains filtered or unexported fields
}

GenericContainer stores generic container data.

func (*GenericContainer) GetContainerIPv4 added in v0.35.0

func (ctr *GenericContainer) GetContainerIPv4() string

func (*GenericContainer) GetContainerIPv6 added in v0.35.0

func (ctr *GenericContainer) GetContainerIPv6() string

func (*GenericContainer) RunExec added in v0.35.0

func (gc *GenericContainer) RunExec(ctx context.Context, execCmd *exec.ExecCmd) (*exec.ExecResult, error)

RunExec executes a single command for a GenericContainer.

func (*GenericContainer) SetRuntime added in v0.35.0

func (ctr *GenericContainer) SetRuntime(r ContainerRuntime)

SetRuntime sets the runtime for this GenericContainer.

type GenericMgmtIPs added in v0.35.0

type GenericMgmtIPs struct {
	IPv4addr string
	IPv4pLen int
	IPv4Gw   string
	IPv6addr string
	IPv6pLen int
	IPv6Gw   string
}

type Initializer added in v0.15.0

type Initializer func() ContainerRuntime

type Node added in v0.44.0

type Node interface {
	Config() *types.NodeConfig
	GetEndpoints() []links.Endpoint
}

Node is an interface that represents a node in the lab and is implemented by containerlab nodes.

type RuntimeConfig added in v0.15.0

type RuntimeConfig struct {
	Timeout          time.Duration
	GracefulShutdown bool
	Debug            bool
	KeepMgmtNet      bool
	VerifyLinkParams *links.VerifyLinkParams
}

type RuntimeOption added in v0.15.0

type RuntimeOption func(ContainerRuntime)

func WithConfig added in v0.15.0

func WithConfig(cfg *RuntimeConfig) RuntimeOption

func WithMgmtNet added in v0.15.0

func WithMgmtNet(mgmt *types.MgmtNet) RuntimeOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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