Documentation
¶
Index ¶
- Constants
- Variables
- func CheckVMImpactsHead(vmID string) bool
- func CleanupAfterDeletion(deletedVMIDs []string) bool
- func ClearHead() error
- func GetAliasByVMID(vmID string) string
- func GetAliasesPath() (string, error)
- func GetCurrentHeadVM() (string, error)
- func GetVmAndNodeIP(ctx context.Context, client *vers.Client, vmID string) (*vers.Vm, string, error)
- func IsHostLocal(hostName string) bool
- func LoadAliases() (map[string]string, error)
- func RemoveAlias(alias string) error
- func ResolveAlias(identifier string) string
- func SaveAliases(aliases map[string]string) error
- func SetAlias(alias, vmID string) error
- func SetHead(vmID string) error
- type VMInfo
- func CreateVMInfoFromVM(vm vers.Vm) *VMInfo
- func GetCurrentHeadVMInfo(ctx context.Context, client *vers.Client) (*VMInfo, error)
- func ResolveVMIdentifier(ctx context.Context, client *vers.Client, identifier string) (*VMInfo, error)
- func SetHeadFromIdentifier(ctx context.Context, client *vers.Client, identifier string) (*VMInfo, error)
Constants ¶
const ( VersDir = ".vers" HeadFile = "HEAD" )
Variables ¶
var ( ErrHeadNotFound = errors.New("head not found") ErrHeadEmpty = errors.New("head empty") )
Functions ¶
func CheckVMImpactsHead ¶
CheckVMImpactsHead checks if a specific VM deletion will affect HEAD
func CleanupAfterDeletion ¶
CleanupAfterDeletion clears HEAD if any of the deleted VM IDs match current HEAD
func GetAliasByVMID ¶ added in v0.5.4
GetAliasByVMID performs a reverse lookup to find an alias for a VM ID Returns empty string if no alias exists
func GetAliasesPath ¶ added in v0.5.4
GetAliasesPath returns the path to the aliases file (~/.vers/aliases.json)
func GetCurrentHeadVM ¶
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 LoadAliases ¶ added in v0.5.4
LoadAliases loads the alias map from ~/.vers/aliases.json Returns an empty map if the file doesn't exist
func RemoveAlias ¶ added in v0.5.4
RemoveAlias removes an alias mapping
func ResolveAlias ¶ added in v0.5.4
ResolveAlias checks if the identifier is an alias and returns the VM ID If not an alias, returns the identifier unchanged
func SaveAliases ¶ added in v0.5.4
SaveAliases saves the alias map to ~/.vers/aliases.json
Types ¶
type VMInfo ¶
VMInfo contains both ID and display name for a VM
func CreateVMInfoFromVM ¶ added in v0.5.0
CreateVMInfoFromVM creates VMInfo from a Vm struct
func GetCurrentHeadVMInfo ¶
GetCurrentHeadVMInfo returns both the HEAD VM ID and its display information