Documentation
¶
Index ¶
- Variables
- func AddControllersForVolumes(ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, ...) (bool, error)
- func AddDefaultNetworkInterface(ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, ...) bool
- func AddToManager(ctx *pkgctx.ControllerManagerContext, mgr ctrlmgr.Manager) error
- func CleanupApplyPowerStateChangeTimeAnno(ctx *pkgctx.WebhookRequestContext, vm, oldVM *vmopv1.VirtualMachine) bool
- func MutateCdromControllerOnUpdate(ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, ...) (bool, error)
- func NewMutator(client ctrlclient.Client) builder.Mutator
- func ResolveClassAndClassName(ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, ...) (bool, error)
- func ResolveImageNameOnCreate(ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, ...) (bool, error)
- func SetCreatedAtAnnotations(ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, ...) (_ bool, _ error)
- func SetDefaultBiosUUID(ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, ...) (bool, error)
- func SetDefaultCdromImgKindOnCreate(ctx *pkgctx.WebhookRequestContext, vm *vmopv1.VirtualMachine)
- func SetDefaultCdromImgKindOnUpdate(ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, ...) (bool, error)
- func SetDefaultControllers(_ *pkgctx.WebhookRequestContext, _ ctrlclient.Client, ...) (_ bool, _ error)
- func SetDefaultEncryptionClass(ctx *pkgctx.WebhookRequestContext, k8sClient ctrlclient.Client, ...) (bool, error)
- func SetDefaultInstanceUUID(ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, ...) (bool, error)
- func SetDefaultNetworkOnUpdate(ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, ...) bool
- func SetDefaultPowerState(ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, ...) bool
- func SetImageNameFromCdrom(ctx *pkgctx.WebhookRequestContext, vm *vmopv1.VirtualMachine)
- func SetLastResizeAnnotations(ctx *pkgctx.WebhookRequestContext, vm, oldVM *vmopv1.VirtualMachine) (bool, error)
- func SetNextRestartTime(ctx *pkgctx.WebhookRequestContext, newVM, oldVM *vmopv1.VirtualMachine) (bool, error)
- func SetPVCVolumeDefaults(ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, ...) (bool, error)
- type MutateOnCreateFn
- type MutateOnUpdateFn
Constants ¶
This section is empty.
Variables ¶
var ( // MutateOnCreateFuncs is used to register functions called when a VM is // created. Values must be type MutateOnCreateFn. MutateOnCreateFuncs sync.Map // MutateOnUpdateFuncs is used to register functions called when a VM is // updated. Values must be type MutateOnUpdateFn. MutateOnUpdateFuncs sync.Map )
Functions ¶
func AddControllersForVolumes ¶ added in v1.10.0
func AddControllersForVolumes( ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
AddControllersForVolumes mutates the VM to add any controllers to the spec if any of the specified volumes cannot be accommodated on the existing controllers. If one of the current controllers (spec.hardware.controllers) is suitable for the volume (e.g., matches the sharing mode), we check if there are any open slots. If none are found, we add a controller.
func AddDefaultNetworkInterface ¶
func AddDefaultNetworkInterface( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, vm *vmopv1.VirtualMachine) bool
AddDefaultNetworkInterface adds default network interface to a VM if the NoNetwork annotation is not set and no NetworkInterface is specified. Return true if default NetworkInterface is added, otherwise return false.
func AddToManager ¶
func AddToManager(ctx *pkgctx.ControllerManagerContext, mgr ctrlmgr.Manager) error
AddToManager adds the webhook to the provided manager.
func CleanupApplyPowerStateChangeTimeAnno ¶ added in v1.10.0
func CleanupApplyPowerStateChangeTimeAnno( ctx *pkgctx.WebhookRequestContext, vm, oldVM *vmopv1.VirtualMachine) bool
func MutateCdromControllerOnUpdate ¶ added in v1.10.0
func MutateCdromControllerOnUpdate( ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, vm, oldVM *vmopv1.VirtualMachine) (bool, error)
MutateCdromControllerOnUpdate mutates CD-ROM controller assignments for VirtualMachine updates. It processes explicit placements (controller type, bus number, and unit number all specified) first to reserve their slots, then assigns implicit placements. For implicit placements, if controller type and bus number are specified, it assigns the next available unit number on that controller. If all fields are empty, it auto-assigns by trying IDE controllers first, then falling back to SATA controllers.
func NewMutator ¶
func NewMutator(client ctrlclient.Client) builder.Mutator
NewMutator returns the package's Mutator.
func ResolveClassAndClassName ¶ added in v1.10.0
func ResolveClassAndClassName( ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
ResolveClassAndClassName resolves the spec.class and spec.className of a VM.
- If spec.className is specified, but spec.class is empty, then spec.class is set to the active instance of the class.
- If a VM class instance is specified in spec.class but spec.className is empty, spec.className is set to the class that is the owner of the class instance.
- If both spec.class and spec.className both are specified, then we ensure that both point to the same class.
func ResolveImageNameOnCreate ¶ added in v1.9.0
func ResolveImageNameOnCreate( ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
ResolveImageNameOnCreate ensures vm.spec.image is set to a non-empty value if vm.spec.imageName is also non-empty.
func SetCreatedAtAnnotations ¶ added in v1.9.0
func SetCreatedAtAnnotations( ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, vm *vmopv1.VirtualMachine) (_ bool, _ error)
func SetDefaultBiosUUID ¶ added in v1.9.0
func SetDefaultBiosUUID( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
SetDefaultBiosUUID sets a default bios uuid for a new VM if one was not provided. If CloudInit is the Bootstrap method, CloudInit InstanceID is also set to BiosUUID. Return true if a default bios uuid was set, otherwise false.
func SetDefaultCdromImgKindOnCreate ¶ added in v1.9.0
func SetDefaultCdromImgKindOnCreate( ctx *pkgctx.WebhookRequestContext, vm *vmopv1.VirtualMachine)
func SetDefaultCdromImgKindOnUpdate ¶ added in v1.9.0
func SetDefaultCdromImgKindOnUpdate( ctx *pkgctx.WebhookRequestContext, _ ctrlclient.Client, vm, oldVM *vmopv1.VirtualMachine) (bool, error)
func SetDefaultControllers ¶ added in v1.10.0
func SetDefaultControllers( _ *pkgctx.WebhookRequestContext, _ ctrlclient.Client, vm *vmopv1.VirtualMachine) (_ bool, _ error)
SetDefaultControllers sets the default device controllers for a VM.
func SetDefaultEncryptionClass ¶ added in v1.9.0
func SetDefaultEncryptionClass( ctx *pkgctx.WebhookRequestContext, k8sClient ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
SetDefaultEncryptionClass assigns spec.crypto.encryptionClassName to the namespace's default EncryptionClass when creating a VM if spec.crypto is nil or spec.crypto.encryptionClassName is empty.
func SetDefaultInstanceUUID ¶ added in v1.9.0
func SetDefaultInstanceUUID( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
SetDefaultInstanceUUID sets a default instance uuid for a new VM. Return true if a default instance uuid was set, otherwise false.
func SetDefaultNetworkOnUpdate ¶ added in v1.10.0
func SetDefaultNetworkOnUpdate( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, vm *vmopv1.VirtualMachine) bool
func SetDefaultPowerState ¶ added in v1.9.0
func SetDefaultPowerState( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, vm *vmopv1.VirtualMachine) bool
SetDefaultPowerState sets the default power state for a new VM. Return true if the default power state was set, otherwise false.
func SetImageNameFromCdrom ¶ added in v1.9.0
func SetImageNameFromCdrom( ctx *pkgctx.WebhookRequestContext, vm *vmopv1.VirtualMachine)
func SetLastResizeAnnotations ¶ added in v1.10.0
func SetLastResizeAnnotations( ctx *pkgctx.WebhookRequestContext, vm, oldVM *vmopv1.VirtualMachine) (bool, error)
SetLastResizeAnnotations sets the last resize annotation as needed when the class name changes.
func SetNextRestartTime ¶ added in v1.9.0
func SetNextRestartTime( ctx *pkgctx.WebhookRequestContext, newVM, oldVM *vmopv1.VirtualMachine) (bool, error)
SetNextRestartTime sets spec.nextRestartTime for a VM if the field's current value is equal to "now" (case-insensitive). Return true if set, otherwise false.
func SetPVCVolumeDefaults ¶ added in v1.10.0
func SetPVCVolumeDefaults( ctx *pkgctx.WebhookRequestContext, c ctrlclient.Client, vm *vmopv1.VirtualMachine) (bool, error)
SetPVCVolumeDefaults sets the default configuration for a volume based on its application type.
Types ¶
type MutateOnCreateFn ¶ added in v1.10.0
type MutateOnCreateFn func( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, newVM *vmopv1.VirtualMachine) (wasMutated bool, _ error)
MutateOnCreateFn is a function called to mutate a VM on create.
type MutateOnUpdateFn ¶ added in v1.10.0
type MutateOnUpdateFn func( ctx *pkgctx.WebhookRequestContext, client ctrlclient.Client, newVM, oldVM *vmopv1.VirtualMachine) (wasMutated bool, _ error)
MutateOnUpdateFn is a function called to mutate a VM on update.