core

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFormatFlag

func AddFormatFlag(cmd *cobra.Command)

AddFormatFlag registers the --format / -o flag on a command.

func CloneVMConfigFromFlags

func CloneVMConfigFromFlags(cmd *cobra.Command, snapCfg *types.SnapshotConfig) (*types.VMConfig, error)

CloneVMConfigFromFlags builds VMConfig for clone commands. Zero-value flags inherit from the snapshot config; explicit values are validated against the snapshot minimums (clone resources must be >= snapshot's).

func CommandContext

func CommandContext(cmd *cobra.Command) context.Context

CommandContext returns command context, falling back to Background.

func EnsureFirmwarePath

func EnsureFirmwarePath(conf *config.Config, bootCfg *types.BootConfig)

EnsureFirmwarePath sets default firmware path for cloudimg boot.

func FindHypervisor added in v0.2.9

func FindHypervisor(ctx context.Context, conf *config.Config, ref string) (hypervisor.Hypervisor, error)

FindHypervisor returns the unique backend that owns ref.

func FormatSize

func FormatSize(bytes int64) string

FormatSize formats a byte count as a human-readable size string.

func InitAllHypervisors added in v0.2.9

func InitAllHypervisors(conf *config.Config) ([]hypervisor.Hypervisor, error)

InitAllHypervisors initializes every backend in deterministic order.

func InitBackends

func InitBackends(ctx context.Context, conf *config.Config) ([]imagebackend.Images, hypervisor.Hypervisor, error)

InitBackends initializes all image backends and the hypervisor.

func InitBridgeNetwork added in v0.3.2

func InitBridgeNetwork(conf *config.Config, bridgeDev string) (network.Network, error)

InitBridgeNetwork creates a TAP-on-bridge network provider.

func InitHypervisor

func InitHypervisor(conf *config.Config) (hypervisor.Hypervisor, error)

InitHypervisor initializes the selected hypervisor backend.

func InitImageBackends

func InitImageBackends(ctx context.Context, conf *config.Config) ([]imagebackend.Images, error)

InitImageBackends initializes only image backends (no hypervisor needed).

func InitImageBackendsForPull

func InitImageBackendsForPull(ctx context.Context, conf *config.Config) (*oci.OCI, *cloudimg.CloudImg, error)

InitImageBackendsForPull returns concrete backend types needed by Pull.

func InitNetwork

func InitNetwork(conf *config.Config) (network.Network, error)

InitNetwork creates the CNI network provider.

func InitSnapshot

func InitSnapshot(conf *config.Config) (snapshot.Snapshot, error)

InitSnapshot initializes the snapshot backend.

func IsURL

func IsURL(ref string) bool

IsURL reports whether ref starts with http:// or https://.

func ListAllVMs added in v0.2.9

func ListAllVMs(ctx context.Context, hypers []hypervisor.Hypervisor) ([]*types.VM, error)

ListAllVMs returns merged VM lists from all backends.

func OutputFormatted

func OutputFormatted(cmd *cobra.Command, data any, tableFn func(w *tabwriter.Writer)) error

OutputFormatted checks --format flag: "json" → JSON, otherwise calls tableFn.

func OutputJSON

func OutputJSON(v any) error

OutputJSON encodes v as indented JSON to stdout.

func ReconcileState

func ReconcileState(vm *types.VM) string

ReconcileState checks actual process liveness to detect stale "running" records.

func ResolveImage

func ResolveImage(ctx context.Context, backends []imagebackend.Images, vmCfg *types.VMConfig) ([]*types.StorageConfig, *types.BootConfig, error)

ResolveImage resolves vmCfg.Image across image backends.

func ResolveImageOwner added in v0.3.1

func ResolveImageOwner(ctx context.Context, backends []imagebackend.Images, ref string) (imagebackend.Images, error)

ResolveImageOwner returns the single backend that owns ref.

func RestoreVMConfigFromFlags

func RestoreVMConfigFromFlags(cmd *cobra.Command, vm *types.VM, snapCfg *types.SnapshotConfig) (*types.VMConfig, error)

RestoreVMConfigFromFlags builds VMConfig for restore commands. Keeps VM's current values by default; CLI flags override. Validates that final values are >= snapshot minimums.

func RouteRefs added in v0.2.9

func RouteRefs(ctx context.Context, hypers []hypervisor.Hypervisor, refs []string) (map[hypervisor.Hypervisor][]string, error)

RouteRefs groups VM refs by owning backend.

func VMConfigFromFlags

func VMConfigFromFlags(cmd *cobra.Command, image string) (*types.VMConfig, error)

VMConfigFromFlags builds VMConfig for create/run commands.

Types

type BaseHandler

type BaseHandler struct {
	ConfProvider func() *config.Config
}

BaseHandler provides shared config access for all command handlers.

func NewBaseHandler

func NewBaseHandler(conf *config.Config) BaseHandler

NewBaseHandler creates a BaseHandler that returns the given config pointer.

func (BaseHandler) Conf

func (h BaseHandler) Conf() (*config.Config, error)

Conf validates and returns the config. All handlers call this first.

func (BaseHandler) Init

Init returns the command context and validated config in one call.

Jump to

Keyboard shortcuts

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