labruntime

package
v0.81.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClabernetesRuntimeName = "c9s"

	ExposeTypeClusterIP    = "ClusterIP"
	ExposeTypeHeadless     = "Headless"
	ExposeTypeLoadBalancer = "LoadBalancer"
	ExposeTypeNone         = "None"
)

Variables

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

Functions

func IsLabRuntimeName

func IsLabRuntimeName(name string) bool

func NormalizeExposeType

func NormalizeExposeType(value string) (string, error)

NormalizeExposeType validates a c9s expose type and returns its canonical CRD spelling.

func Register

func Register(name string, init Initializer)

Types

type ChangeAction

type ChangeAction string
const (
	ChangeCreate ChangeAction = "create"
	ChangeUpdate ChangeAction = "update"
	ChangeDelete ChangeAction = "delete"
	// ChangeRecreate marks a resource that is deleted and created again, such as the Pod
	// of a node whose links change. It is not a Kubernetes action; it communicates the
	// lifecycle impact of an apply.
	ChangeRecreate ChangeAction = "recreate"
)

type Config

type Config struct {
	Timeout   time.Duration
	Namespace string

	// KindLinkApplyMode resolves the default link apply mode ("live", "restart" or
	// "recreate") a node kind declares, as containerlab's node registry reports it. An
	// empty result means the kind is unknown and the conservative recreate default
	// applies. Lab runtimes use it to predict the node lifecycle impact of link changes.
	KindLinkApplyMode func(kind string) string
}

type DeployPlan

type DeployPlan struct {
	LabName   string           `json:"lab-name"`
	Namespace string           `json:"namespace"`
	Changes   []ResourceChange `json:"changes"`
}

DeployPlan describes the remote resources a lab runtime would change without mutating them.

type DeployRequest

type DeployRequest struct {
	Name               string
	Namespace          string
	Owner              string
	TopologyFile       string
	TopologyLabDir     string
	TopologyDefinition []byte
	Wait               bool
	Timeout            time.Duration
	// MaxWorkers limits concurrent independent operations performed by the runtime.
	MaxWorkers uint
	// NoTopologyCR deploys without a controller-owned topology object: the runtime compiles the
	// topology client-side and manages the individual lab resources directly.
	NoTopologyCR bool
	// ImagePullSecret names the same-namespace Docker-config Secret placed on device pods
	// through Pod.spec.imagePullSecrets. Empty means the lab references no pull secret at
	// all: public images and clusters whose runtime already holds credentials need none.
	ImagePullSecret string
	// ExposeType controls the Kubernetes Service type c9s creates for lab nodes. Empty uses the
	// c9s CRD default.
	ExposeType string
	// NoPersistence deploys the lab on ephemeral node storage. By default every node's
	// artifact volume is backed by a persistent claim so saved device configuration survives
	// Pod replacement, matching the local-runtime lab directory contract; opting out trades
	// that for not needing a dynamically provisionable storage class, and every Pod
	// replacement then resets the node to its declared configuration.
	NoPersistence bool
}

type DestroyRequest

type DestroyRequest struct {
	Name       string
	Namespace  string
	Wait       bool
	Timeout    time.Duration
	MaxWorkers uint
}

type Event

type Event struct {
	Timestamp   time.Time
	Type        string
	Action      string
	ActorID     string
	ActorName   string
	ActorFullID string
	Attributes  map[string]string
}

type EventStreamRequest

type EventStreamRequest struct {
	Namespace             string
	AllNamespaces         bool
	IncludeInitialState   bool
	IncludeInterfaceStats bool
	StatsInterval         time.Duration
}

type ExecRequest

type ExecRequest struct {
	Name      string
	Namespace string
	NodeName  string
	Command   []string
}

type Initializer

type Initializer func(Config) (LabRuntime, error)

type InspectRequest

type InspectRequest struct {
	Name      string
	Namespace string
}

type LabExistenceChecker

type LabExistenceChecker interface {
	LabExists(context.Context, InspectRequest) (bool, error)
}

LabExistenceChecker lets controller-driven runtimes report whether a lab has remote state. Core uses it to distinguish a fresh deployment from reconciliation without consulting the local container runtime.

type LabState

type LabState struct {
	Name         string
	Namespace    string
	Owner        string
	TopologyPath string
	State        string
	Ready        bool
	Nodes        []NodeState
}

type ListRequest

type ListRequest struct {
	Namespace     string
	AllNamespaces bool
}

type Manifest

type Manifest struct {
	APIVersion string
	Kind       string
	Namespace  string
	Name       string
	Object     map[string]any
}

Manifest is one remote resource a lab runtime would create for a topology, ready to be serialized and applied by hand. Object is the complete resource including its type and metadata; the identity fields are duplicated for summaries and tests.

type ManifestEmitter

type ManifestEmitter interface {
	Manifests(context.Context, DeployRequest) ([]Manifest, error)
}

ManifestEmitter renders the exact resources a lab runtime would create for a topology, in apply order, without reading or changing remote state.

type NodeRequest

type NodeRequest struct {
	Name      string
	Namespace string
	Nodes     []string
	Timeout   time.Duration
}

type NodeState

type NodeState struct {
	Name  string
	Kind  string
	Image string
	State string
	Ready bool
	// MgmtIPv4Address and MgmtIPv6Address are the node's allocated management addresses in
	// CIDR notation, when the runtime reports them.
	MgmtIPv4Address     string
	MgmtIPv6Address     string
	LoadBalancerAddress string
}

type ResourceChange

type ResourceChange struct {
	Action    ChangeAction `json:"action"`
	Kind      string       `json:"kind"`
	Namespace string       `json:"namespace,omitempty"`
	Name      string       `json:"name"`
}

type SaveRequest

type SaveRequest struct {
	Name      string
	Namespace string
	Nodes     []string
	Copy      bool
}

type SaveResult

type SaveResult struct {
	Files []SavedFile
}

type SavedFile

type SavedFile struct {
	NodeName   string
	Name       string
	Data       []byte
	Mode       int64
	LinkTarget string
}

type TopologyPlanner

type TopologyPlanner interface {
	Plan(context.Context, DeployRequest) (*DeployPlan, error)
}

TopologyPlanner compiles and diffs a desired topology without changing remote state.

type TopologyValidator

type TopologyValidator interface {
	Validate(context.Context, DeployRequest) error
}

TopologyValidator validates the runtime-specific topology subset without changing remote state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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