core

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 26 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 command context, fallback to Background.

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 checks whether the exact base image (by digest) required by vmCfg exists locally and pulls it if missing. Inspect uses ImageDigest to match the exact version recorded at snapshot time; Pull uses Image (tag/URL) as the registry reference, then verifies the pulled digest.

For imported images (not pullable from a registry), a warning is logged and the caller proceeds — VerifyBaseFiles will catch the actual 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 (allows overrides).

func RouteRefs added in v0.2.9

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

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)

Conf validates and returns the config.

func (BaseHandler) Init

Init returns command context and validated config.

Jump to

Keyboard shortcuts

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