mirror of
https://github.com/harvester/vm-import-controller.git
synced 2025-06-03 01:44:51 +00:00
Replace k8s.io/utils/pointer
with k8s.io/utils/ptr
(#83)
Additionally remove useless explicit type argument lists. Signed-off-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
parent
eefd7000ac
commit
2bd7d3cb9e
@ -125,13 +125,13 @@ const (
|
||||
)
|
||||
|
||||
func (in *VirtualMachineImport) GetDefaultDiskBusType() kubevirtv1.DiskBus {
|
||||
return ptr.Deref[kubevirtv1.DiskBus](in.Spec.DefaultDiskBusType, kubevirtv1.DiskBusVirtio)
|
||||
return ptr.Deref(in.Spec.DefaultDiskBusType, kubevirtv1.DiskBusVirtio)
|
||||
}
|
||||
|
||||
func (in *VirtualMachineImport) GetDefaultNetworkInterfaceModel() string {
|
||||
return ptr.Deref[string](in.Spec.DefaultNetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
||||
return ptr.Deref(in.Spec.DefaultNetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
||||
}
|
||||
|
||||
func (in *NetworkMapping) GetNetworkInterfaceModel() string {
|
||||
return ptr.Deref[string](in.NetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
||||
return ptr.Deref(in.NetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
kubevirt "kubevirt.io/api/core/v1"
|
||||
)
|
||||
|
||||
@ -9,12 +9,12 @@ func VMSpecSetupUEFISettings(vmSpec *kubevirt.VirtualMachineSpec, secureBoot, tp
|
||||
firmware := &kubevirt.Firmware{
|
||||
Bootloader: &kubevirt.Bootloader{
|
||||
EFI: &kubevirt.EFI{
|
||||
SecureBoot: pointer.Bool(false),
|
||||
SecureBoot: ptr.To(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
if secureBoot {
|
||||
firmware.Bootloader.EFI.SecureBoot = pointer.Bool(true)
|
||||
firmware.Bootloader.EFI.SecureBoot = ptr.To(true)
|
||||
}
|
||||
vmSpec.Template.Spec.Domain.Firmware = firmware
|
||||
if tpm {
|
||||
@ -22,7 +22,7 @@ func VMSpecSetupUEFISettings(vmSpec *kubevirt.VirtualMachineSpec, secureBoot, tp
|
||||
}
|
||||
if secureBoot || tpm {
|
||||
vmSpec.Template.Spec.Domain.Features.SMM = &kubevirt.FeatureState{
|
||||
Enabled: pointer.Bool(true),
|
||||
Enabled: ptr.To(true),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
kubevirt "kubevirt.io/api/core/v1"
|
||||
|
||||
@ -253,8 +252,8 @@ func (c *Client) ExportVirtualMachine(vm *migration.VirtualMachineImport) error
|
||||
"name": vm.Name,
|
||||
"namespace": vm.Namespace,
|
||||
"spec.virtualMachineName": vm.Spec.VirtualMachineName,
|
||||
"snapshot.id": ptr.Deref[snapshots.Snapshot](snapshot, snapshots.Snapshot{}).ID,
|
||||
"volume.id": ptr.Deref[volumes.Volume](volume, volumes.Volume{}).ID,
|
||||
"snapshot.id": ptr.Deref(snapshot, snapshots.Snapshot{}).ID,
|
||||
"volume.id": ptr.Deref(volume, volumes.Volume{}).ID,
|
||||
"volumeImage.imageID": volumeImage.ImageID,
|
||||
}).Info("Cleaning up resources on OpenStack source")
|
||||
|
||||
@ -555,7 +554,7 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
|
||||
},
|
||||
Features: &kubevirt.Features{
|
||||
ACPI: kubevirt.FeatureState{
|
||||
Enabled: pointer.Bool(true),
|
||||
Enabled: ptr.To(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
kubevirt "kubevirt.io/api/core/v1"
|
||||
|
||||
migration "github.com/harvester/vm-import-controller/pkg/apis/migration.harvesterhci.io/v1beta1"
|
||||
@ -354,7 +354,7 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
|
||||
},
|
||||
Features: &kubevirt.Features{
|
||||
ACPI: kubevirt.FeatureState{
|
||||
Enabled: pointer.Bool(true),
|
||||
Enabled: ptr.To(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -369,9 +369,9 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
|
||||
uefi := strings.EqualFold(o.Config.Firmware, string(types.GuestOsDescriptorFirmwareTypeEfi))
|
||||
secureBoot := false
|
||||
if o.Config.BootOptions != nil {
|
||||
secureBoot = pointer.BoolDeref(o.Config.BootOptions.EfiSecureBootEnabled, false)
|
||||
secureBoot = ptr.Deref(o.Config.BootOptions.EfiSecureBootEnabled, false)
|
||||
}
|
||||
tpm := pointer.BoolDeref(o.Summary.Config.TpmPresent, false)
|
||||
tpm := ptr.Deref(o.Summary.Config.TpmPresent, false)
|
||||
if uefi {
|
||||
source.VMSpecSetupUEFISettings(&vmSpec, secureBoot, tpm)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/vmware/govmomi/vim25/types"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
kubevirt "kubevirt.io/api/core/v1"
|
||||
|
||||
migration "github.com/harvester/vm-import-controller/pkg/apis/migration.harvesterhci.io/v1beta1"
|
||||
@ -319,7 +319,7 @@ func Test_GenerateVirtualMachine_secureboot(t *testing.T) {
|
||||
GuestId: string(types.VirtualMachineGuestOsIdentifierOtherGuest64),
|
||||
Firmware: string(types.GuestOsDescriptorFirmwareTypeEfi),
|
||||
BootOptions: &types.VirtualMachineBootOptions{
|
||||
EfiSecureBootEnabled: pointer.Bool(true),
|
||||
EfiSecureBootEnabled: ptr.To(true),
|
||||
},
|
||||
Files: &types.VirtualMachineFileInfo{
|
||||
VmPathName: fmt.Sprintf("[%s] %s", ds.Name(), vm.Spec.VirtualMachineName),
|
||||
@ -377,7 +377,7 @@ func Test_identifyNetworkCards(t *testing.T) {
|
||||
{
|
||||
SourceNetwork: "DVSwitch: fea97929-4b2d-5972-b146-930c6d0b4014",
|
||||
DestinationNetwork: "pod-network",
|
||||
NetworkInterfaceModel: pointer.String(migration.NetworkInterfaceModelRtl8139),
|
||||
NetworkInterfaceModel: ptr.To(migration.NetworkInterfaceModelRtl8139),
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user