Documentation
¶
Index ¶
- func HasSubProperties(name Name) bool
- func InitDefinitions() error
- type Name
- type PropertyInfo
- type PropertyType
- type RawPropertySet
- func (p *RawPropertySet[T]) Add(key Name, val any) error
- func (p RawPropertySet[T]) Get(n Name) (PropertyInfo, error)
- func (p RawPropertySet[T]) GetAll() map[Name]PropertyInfo
- func (p RawPropertySet[T]) GetSubProperties(n Name) (RawPropertySet[T], error)
- func (p RawPropertySet[T]) GetValue(n Name) (any, error)
- func (p RawPropertySet[T]) ToAPI(unsupportedDisks map[string]bool) (*api.InstanceProperties, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasSubProperties ¶
HasSubProperties returns whether this is a property with sub-properties.
func InitDefinitions ¶
func InitDefinitions() error
InitDefinitions initializes the global property list.
Types ¶
type Name ¶
type Name int
Name is the keyword defining a property.
const ( // InstanceSnapshots is the property name for instance snapshots. InstanceSnapshots Name = iota // InstanceDisks is the property name for instance disks. InstanceDisks // InstanceNICs is the property name for instance nics. InstanceNICs // InstanceUUID is the property name for instance UUID. InstanceUUID // InstanceName is the property name for instance Name. InstanceName // InstanceLocation is the property name for the location of the instance. InstanceLocation // InstanceCPUs is the property name for the number of cpus available to the instance. InstanceCPUs // InstanceMemory is the property name for the amount of memory available to the instance in bytes. InstanceMemory // InstanceOS is the property name for the OS type of the instance. InstanceOS // InstanceOSVersion is the property name for the OS version of the instance. InstanceOSVersion // InstanceLegacyBoot is the property name for whether the instance uses legacy boot. InstanceLegacyBoot // InstanceSecureBoot is the property name for whether the instance uses secure boot. InstanceSecureBoot // InstanceTPM is the property name for whether the instance has a TPM. InstanceTPM // InstanceDescription is the property name of the description of the instance. InstanceDescription // InstanceBackgroundImport is the property name for whether the instance supports background import during a migration. InstanceBackgroundImport // InstanceArchitecture is the property name for the architecture of the instance. InstanceArchitecture // InstanceConfig is the property name for generic instance config. InstanceConfig // InstanceNICHardwareAddress is the property name for an instance nic's hardware address. InstanceNICHardwareAddress // InstanceNICNetwork is the property name for the name of the network entity used by the instance. InstanceNICNetwork // InstanceNICNetworkID is the property name for the unique identifier of the network entity used by the instance. InstanceNICNetworkID // InstanceNICNetworkID is the property name for ipv4 address of the nic. InstanceNICIPv4Address // InstanceNICNetworkID is the property name for ipv6 address of the nic. InstanceNICIPv6Address // InstanceDiskCapacity is the property name for an instance disk's capacity in bytes. InstanceDiskCapacity InstanceDiskShared // InstanceDiskName is the property name for an instance disk's name. InstanceDiskName // InstanceSnapshotName is the property name for the name of an instance snapshot. InstanceSnapshotName )
func ParseInstanceDiskProperty ¶
ParseInstanceDiskProperty parses the string as a valid instance disk property.
func ParseInstanceNICProperty ¶
ParseInstanceNICProperty parses the string as a valid instance NIC property.
func ParseInstanceProperty ¶
ParseInstanceProperty parses the string as a valid instance property.
func ParseInstanceSnapshotProperty ¶
ParseInstanceSnapshotProperty parses the string as a valid instance snapshot property.
type PropertyInfo ¶
type PropertyInfo struct { // Type is the type of entity on the target or source holding the configuration. Type PropertyType `json:"type,omitempty" yaml:"type,omitempty"` // Key represents the map key name holding the value for the propery. Key string `json:"key" yaml:"key"` }
PropertyInfo represents a type of property on a source or target, and the key to acces it.
type PropertyType ¶
type PropertyType string
PropertyType is the type of property on the source or target.
const ( // TypeVMInfo represents top-level VM information from VMware. TypeVMInfo PropertyType = "vm_info" // TypeGuestInfo represents the guestInfo key-value pairs from VMware. TypeGuestInfo PropertyType = "guest_info" // TypeVMProperty represents the VM property configuration for VMware. TypeVMProperty PropertyType = "property" // TypeVMPropertyDisk represents a VM's virtual disk configuration for VMware. TypeVMPropertyDisk PropertyType = "property_disk" // TypeVMPropertyEthernet represents a VM's ethernet configuration for VMware. TypeVMPropertyEthernet PropertyType = "property_ethernet" // TypeVMPropertySnapshot represents a VM's snapshot configuration for VMware. TypeVMPropertySnapshot PropertyType = "property_snapshot" // TypeConfig represents Incus instance config. TypeConfig PropertyType = "config" // TypeDisk represents Incus disk device config. TypeDisk PropertyType = "disk" // TypeNIC represents Incus nic device config. TypeNIC PropertyType = "nic" // TypeTPM represents Incus tpm device config. TypeTPM PropertyType = "tpm" )
type RawPropertySet ¶
type RawPropertySet[T api.SourceType | api.TargetType] struct { // contains filtered or unexported fields }
RawPropertySet holds the set of definitions for a particular source or target and version.
func Definitions ¶
func Definitions[T api.SourceType | api.TargetType](t T, version string) (RawPropertySet[T], error)
Definitions generates a new RawPropertySet with all supported property definitions for the given target or source and version.
func (*RawPropertySet[T]) Add ¶
func (p *RawPropertySet[T]) Add(key Name, val any) error
Add stores the given value for the named property, performing type validation. If the property name is a property with sub-properties, the value is expected to be a RawPropertySet[T]. If it receives a property name that is a sub-property key, it validates that the value must be non-empty (The whole sub-property object must be defined).
func (RawPropertySet[T]) Get ¶
func (p RawPropertySet[T]) Get(n Name) (PropertyInfo, error)
Get returns the named property definition, if supported by this target or source.
func (RawPropertySet[T]) GetAll ¶
func (p RawPropertySet[T]) GetAll() map[Name]PropertyInfo
GetAll returns a map of all properties and their definitions supported by this target or source.
func (RawPropertySet[T]) GetSubProperties ¶
func (p RawPropertySet[T]) GetSubProperties(n Name) (RawPropertySet[T], error)
GetSubProperties returns the RawPropertySet for the sub-properties of the named property, if supported by this target or source.
func (RawPropertySet[T]) GetValue ¶
func (p RawPropertySet[T]) GetValue(n Name) (any, error)
GetValue returns the stored value for the property, if one exists. Cannot be used to fetch a group of sub-properties.
func (RawPropertySet[T]) ToAPI ¶
func (p RawPropertySet[T]) ToAPI(unsupportedDisks map[string]bool) (*api.InstanceProperties, error)
ToAPI converts the raw properties list to an API compatible type. Since we already validated the inputs when calling Add, this just remarshals the value maps as the API type.