core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFormatFlag

func AddFormatFlag(cmd *cobra.Command)

func AddOutputFlag added in v0.3.7

func AddOutputFlag(cmd *cobra.Command)

AddOutputFlag adds --output/-o for lifecycle commands. Empty default keeps the human-readable log output; "json" emits a parseable result on stdout.

func CloneVMConfigFromFlags

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

CloneVMConfigFromFlags builds VMConfig for clone (inherits from snapshot).

func CommandContext

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

CommandContext returns cmd.Context() or Background (test-only fallback).

func EnsureFirmwarePath

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

func EnsureImage added in v0.3.6

func EnsureImage(ctx context.Context, backends []imagebackend.Images, vmCfg *types.VMConfig)

EnsureImage pulls the digest-pinned base image if missing locally; warns (rather than fails) for imported images so VerifyBaseFiles surfaces the real error.

func FindHypervisor added in v0.2.9

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

func FormatSize

func FormatSize(bytes int64) string

func InitAllHypervisors added in v0.2.9

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

func InitBridgeNetwork added in v0.3.2

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

func InitHypervisor

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

func InitImageBackends

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

func InitImageBackendsForPull

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

func InitNetwork

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

func InitSnapshot

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

func IsURL

func IsURL(ref string) bool

func ListAllVMs added in v0.2.9

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

func MaybeOutputJSON added in v0.3.7

func MaybeOutputJSON(cmd *cobra.Command, v any) (bool, error)

MaybeOutputJSON emits v as JSON iff --output=json is set. Returns (true, encodeErr) when JSON was emitted — caller should return the error without falling through to human-readable logging. Returns (false, nil) otherwise so the caller proceeds with normal log output.

func OutputFormatted

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

OutputFormatted outputs as JSON or table based on --format flag.

func OutputJSON

func OutputJSON(v any) error

func ReconcileState

func ReconcileState(vm *types.VM) string

ReconcileState detects stale running records via process liveness.

func ResolveImage

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

func ResolveImageOwner added in v0.3.1

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

func RestoreVMConfigFromFlags

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

RestoreVMConfigFromFlags builds VMConfig for restore: resources from the snapshot, Name/Network from the VM (CNI namespace survives restore).

func RouteRefs added in v0.2.9

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

RouteRefs resolves each user ref (full ID, name, or ID prefix) to its owning hypervisor and returns a map of owner → resolved full VM IDs. Returning full IDs (not raw refs) ensures downstream code — including network recovery and lifecycle batchers — never has to re-resolve prefixes.

func VMConfigFromFlags

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

func WantJSON added in v0.3.7

func WantJSON(cmd *cobra.Command) bool

WantJSON reports whether --output=json was requested.

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

func (BaseHandler) Conf

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

func (BaseHandler) Init

Jump to

Keyboard shortcuts

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