vmconfig

package
v0.7.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GuestOSWindows = "windows"
	GuestOSLinux   = "linux"

	ProfileUsageOrdinary          = "ordinary"
	ProfileUsageLinuxImageBuilder = "linux_image_builder"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DefaultProfile      string             `json:"default_profile,omitempty"`
	TargetDefaults      map[string]string  `json:"target_defaults,omitempty"`
	DefaultLinuxProfile string             `json:"default_linux_profile,omitempty"`
	LinuxTargetDefaults map[string]string  `json:"linux_target_defaults,omitempty"`
	Profiles            map[string]Profile `json:"profiles,omitempty"`
}

Config is loaded from ~/.lablink/vm-defaults.json by default.

func (Config) Names

func (c Config) Names() []string

type Profile

type Profile struct {
	Target                            string  `json:"target,omitempty"`
	GuestOS                           string  `json:"guest_os,omitempty"`
	ProfileUsage                      string  `json:"profile_usage,omitempty"`
	BaseVHD                           string  `json:"base_vhd,omitempty"`
	VMRoot                            string  `json:"vm_root,omitempty"`
	VSwitch                           string  `json:"vswitch,omitempty"`
	AdminCredential                   string  `json:"admin_password_credential,omitempty"`
	MemoryMB                          float64 `json:"memory_mb,omitempty"`
	CPUCount                          float64 `json:"cpu_count,omitempty"`
	DynamicMemory                     bool    `json:"dynamic_memory,omitempty"`
	DynamicMinMB                      float64 `json:"dynamic_min_mb,omitempty"`
	DynamicMaxMB                      float64 `json:"dynamic_max_mb,omitempty"`
	DynamicBufferPct                  float64 `json:"dynamic_buffer_pct,omitempty"`
	SecureBoot                        *bool   `json:"secure_boot,omitempty"`
	Locale                            string  `json:"locale,omitempty"`
	TimeZone                          string  `json:"timezone,omitempty"`
	AutoLogon                         bool    `json:"auto_logon,omitempty"`
	ObfuscatePassword                 bool    `json:"obfuscate_password,omitempty"`
	RegisterLabLink                   *bool   `json:"register_with_lablink,omitempty"`
	LabLinkRole                       string  `json:"lablink_role,omitempty"`
	LabLinkPort                       int     `json:"lablink_port,omitempty"`
	MinHostReservePct                 float64 `json:"min_host_reserve_pct,omitempty"`
	ExposeVirtualizationExtensions    *bool   `json:"expose_virtualization_extensions,omitempty"`
	VirtualizationBasedSecurityOptOut *bool   `json:"virtualization_based_security_opt_out,omitempty"`
	Distribution                      string  `json:"distribution,omitempty"`
	Release                           string  `json:"release,omitempty"`
	Architecture                      string  `json:"architecture,omitempty"`
	ImageCacheRoot                    string  `json:"image_cache_root,omitempty"`
	LinuxUsername                     string  `json:"linux_username,omitempty"`
	SSHPublicKey                      string  `json:"ssh_public_key,omitempty"`
	SSHPublicKeyFile                  string  `json:"ssh_public_key_file,omitempty"`
	LinuxPasswordCredential           string  `json:"linux_password_credential,omitempty"`
	AllowSSHPasswordAuth              *bool   `json:"allow_ssh_password_auth,omitempty"`
	NetworkConfig                     string  `json:"network_config,omitempty"`
	DiskSizeGB                        float64 `json:"disk_size_gb,omitempty"`
	ImageBuilderProfile               string  `json:"image_builder_profile,omitempty"`
	BuilderVMName                     string  `json:"builder_vm_name,omitempty"`
	DeleteBuilderAfterPrepare         *bool   `json:"delete_builder_after_prepare,omitempty"`
}

Profile contains non-secret defaults for creating a Hyper-V VM. AdminCredential is a credential-store profile name, never a password. GuestOS is backward-compatible: empty means Windows.

func (Profile) EffectiveGuestOS added in v0.7.0

func (p Profile) EffectiveGuestOS() (string, error)

EffectiveGuestOS normalizes guest_os. Empty is Windows for compatibility.

func (Profile) EffectiveProfileUsage added in v0.7.0

func (p Profile) EffectiveProfileUsage() (string, error)

EffectiveProfileUsage normalizes profile_usage. Empty remains ordinary for compatibility with profiles created before usage classification existed.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is an immutable loaded defaults file.

func Load

func Load(path string) *Store

Load reads VM defaults. A missing file is valid and yields an empty store; malformed content is retained as an error so callers do not silently ignore a broken autonomous-creation policy.

func (*Store) Delete

func (s *Store) Delete(name string) error

func (*Store) IsLinuxImageBuilderProfile added in v0.7.0

func (s *Store) IsLinuxImageBuilderProfile(name string) (bool, error)

IsLinuxImageBuilderProfile reports whether a Windows profile is explicitly classified as a Linux image builder or is referenced by any Linux profile. Reference inference preserves existing configurations created before profile_usage was introduced.

func (*Store) List

func (s *Store) List() (Config, error)

func (*Store) Path

func (s *Store) Path() string

func (*Store) Resolve

func (s *Store) Resolve(name string) (Profile, string, error)

Resolve returns the requested profile, or the configured default when name is empty. The returned name is the actual selected profile.

func (*Store) ResolveForTarget

func (s *Store) ResolveForTarget(name, target string) (Profile, string, error)

ResolveForTarget selects an explicit profile, then a target-specific default, then the global default.

func (*Store) ResolveLinux added in v0.7.0

func (s *Store) ResolveLinux(name string) (Profile, string, error)

ResolveLinux returns a Linux profile using default_linux_profile and linux_target_defaults.

func (*Store) ResolveLinuxForTarget added in v0.7.0

func (s *Store) ResolveLinuxForTarget(name, target string) (Profile, string, error)

ResolveLinuxForTarget selects an explicit Linux profile, then the Linux-specific target default, then the Linux-specific global default.

func (*Store) ResolveOrdinaryWindowsForTarget added in v0.7.0

func (s *Store) ResolveOrdinaryWindowsForTarget(name, target string) (Profile, string, error)

ResolveOrdinaryWindowsForTarget resolves the profile used by the public create_windows_vm tool and rejects builder-only profiles. Internal Linux image preparation intentionally uses ResolveWindowsForTarget instead.

func (*Store) ResolveWindows added in v0.7.0

func (s *Store) ResolveWindows(name string) (Profile, string, error)

ResolveWindows returns a Windows profile using the legacy default_profile and target_defaults selectors. Profiles with an empty guest_os are Windows.

func (*Store) ResolveWindowsForTarget added in v0.7.0

func (s *Store) ResolveWindowsForTarget(name, target string) (Profile, string, error)

ResolveWindowsForTarget selects an explicit Windows profile, then the legacy target-specific default, then the legacy global default.

func (*Store) Set

func (s *Store) Set(name string, profile Profile, targetDefault bool) error

Jump to

Keyboard shortcuts

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