utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersDir  = ".vers"
	HeadFile = "HEAD"
)

Variables

View Source
var (
	ErrHeadNotFound = errors.New("head not found")
	ErrHeadEmpty    = errors.New("head empty")
)

Functions

func CheckVMImpactsHead

func CheckVMImpactsHead(vmID string) bool

CheckVMImpactsHead checks if a specific VM deletion will affect HEAD

func CleanupAfterDeletion

func CleanupAfterDeletion(deletedVMIDs []string) bool

CleanupAfterDeletion clears HEAD if any of the deleted VM IDs match current HEAD

func ClearHead

func ClearHead() error

ClearHead clears the HEAD file

func GetCurrentHeadVM

func GetCurrentHeadVM() (string, error)

GetCurrentHeadVM returns the VM ID from the current HEAD

func GetVmAndNodeIP

func GetVmAndNodeIP(ctx context.Context, client *vers.Client, vmID string) (*vers.Vm, string, error)

GetVmAndNodeIP retrieves VM information and the node IP from headers in a single request. We use the lower-level client.Get() instead of client.Vm.List() because we need response headers.

func IsHostLocal

func IsHostLocal(hostName string) bool

func SetHead

func SetHead(vmID string) error

SetHead sets the HEAD to point to a specific VM ID (always stores ID, never alias)

Types

type VMInfo

type VMInfo struct {
	ID          string
	DisplayName string
}

VMInfo contains both ID and display name for a VM

func CreateVMInfoFromVM added in v0.5.0

func CreateVMInfoFromVM(vm vers.Vm) *VMInfo

CreateVMInfoFromVM creates VMInfo from a Vm struct

func GetCurrentHeadVMInfo

func GetCurrentHeadVMInfo(ctx context.Context, client *vers.Client) (*VMInfo, error)

GetCurrentHeadVMInfo returns both the HEAD VM ID and its display information

func ResolveVMIdentifier

func ResolveVMIdentifier(ctx context.Context, client *vers.Client, vmID string) (*VMInfo, error)

ResolveVMIdentifier takes a VM ID and returns the VM info Note: Alias lookups are no longer supported in the new SDK

func SetHeadFromIdentifier

func SetHeadFromIdentifier(ctx context.Context, client *vers.Client, identifier string) (*VMInfo, error)

SetHeadFromIdentifier resolves a VM identifier to an ID and sets HEAD

Jump to

Keyboard shortcuts

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