Documentation
¶
Index ¶
- Constants
- Variables
- func Register(name string, initFn Initializer)
- func WaitForContainerRunning(ctx context.Context, r ContainerRuntime, contName, nodeName string) error
- type ContainerEvent
- type ContainerMount
- type ContainerRuntime
- type ContainerStatus
- type EndpointlessNode
- type EventStreamOptions
- type GenericContainer
- type GenericMgmtIPs
- type GraphDriver
- type GraphDriverData
- type ImageConfig
- type ImageInspect
- type Initializer
- type Node
- type RootFS
- type RuntimeConfig
- type RuntimeOption
Constants ¶
View Source
const ( NotFound = "NotFound" Running = "Running" Stopped = "Stopped" )
View Source
const ( EventActionStart = "start" EventActionUnpause = "unpause" EventActionRestart = "restart" EventActionDie = "die" EventActionStop = "stop" EventActionDestroy = "destroy" EventActionKill = "kill" )
View Source
const (
EventTypeContainer = "container"
)
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 ContainerEvent ¶ added in v0.72.0
type ContainerMount ¶ added in v0.35.0
type ContainerRuntime ¶
type ContainerRuntime interface {
// Initializes the Container runtime struct
Init(...RuntimeOption) error
// Mgmt return management network configuration of a runtime
Mgmt() *clabtypes.MgmtNet
// Adds custom configuration items to the container runtime struct
WithConfig(*RuntimeConfig)
// Set the network management details (generated by the config.go)
WithMgmtNet(*clabtypes.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, clabtypes.PullPolicyValue) error
// CreateContainer creates a container, but does not start it
CreateContainer(context.Context, *clabtypes.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) (any, 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, []*clabtypes.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 *clabexec.ExecCmd) (*clabexec.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 *clabexec.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)
// Immediately write to the stdin of a container, returns error
WriteToStdinNoWait(ctx context.Context, cID string, data []byte) error
// CheckConnectivity returns an error if it cannot connect to the runtime, nil otherwise
CheckConnection(ctx context.Context) error
// GetRuntimeSocket returns the path to the control socket
GetRuntimeSocket() (string, error)
// GetCooCBindMounts returns the extra mounts a container running this runtime in
// Container-outside-of-Container (CooC - General case – container uses host container
// runtime) does need to function properly
GetCooCBindMounts() clabtypes.Binds
// StreamLogs returns a reader for the container's logs
// The caller needs to close the returned ReadCloser.
StreamLogs(ctx context.Context, containerName string) (io.ReadCloser, error)
// StreamEvents streams runtime events that match provided options.
StreamEvents(
ctx context.Context,
opts EventStreamOptions,
) (<-chan ContainerEvent, <-chan error, error)
// InspectImage returns detailed information about a container image
InspectImage(ctx context.Context, imageName string) (*ImageInspect, error)
}
type ContainerStatus ¶ added in v0.32.0
type ContainerStatus string
type EndpointlessNode ¶ added in v0.71.0
type EndpointlessNode struct {
// contains filtered or unexported fields
}
func (*EndpointlessNode) Config ¶ added in v0.71.0
func (n *EndpointlessNode) Config() *clabtypes.NodeConfig
func (*EndpointlessNode) GetEndpoints ¶ added in v0.71.0
func (*EndpointlessNode) GetEndpoints() []clablinks.Endpoint
type EventStreamOptions ¶ added in v0.72.0
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
NetworkName string
NetworkSettings GenericMgmtIPs
Mounts []ContainerMount
Runtime ContainerRuntime
Ports []*clabtypes.GenericPortBinding
}
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 *clabexec.ExecCmd, ) (*clabexec.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 GraphDriver ¶ added in v0.72.0
type GraphDriver struct {
Name string
Data GraphDriverData
}
GraphDriver holds information about the storage driver.
type GraphDriverData ¶ added in v0.72.0
GraphDriverData holds the driver-specific data.
type ImageConfig ¶ added in v0.72.0
ImageConfig holds image configuration data.
type ImageInspect ¶ added in v0.72.0
type ImageInspect struct {
ID string
Config ImageConfig
RootFS RootFS
GraphDriver GraphDriver
}
ImageInspect holds relevant image inspection data.
type Initializer ¶ added in v0.15.0
type Initializer func() ContainerRuntime
type Node ¶ added in v0.44.0
type Node interface {
Config() *clabtypes.NodeConfig
GetEndpoints() []clablinks.Endpoint
}
Node is an interface that represents a node in the lab and is implemented by containerlab nodes.
func NewEndpointlessNode ¶ added in v0.71.0
func NewEndpointlessNode(c *clabtypes.NodeConfig) Node
NewEndpointlessNode returns a EndpointlessNode -- a node w/ only a config, that can satisfy the Node interface.
type RuntimeConfig ¶ added in v0.15.0
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 *clabtypes.MgmtNet) RuntimeOption
Click to show internal directories.
Click to hide internal directories.