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 {
|
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 {
|
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 {
|
func (in *NetworkMapping) GetNetworkInterfaceModel() string {
|
||||||
return ptr.Deref[string](in.NetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
return ptr.Deref(in.NetworkInterfaceModel, NetworkInterfaceModelVirtio)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package source
|
package source
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/ptr"
|
||||||
kubevirt "kubevirt.io/api/core/v1"
|
kubevirt "kubevirt.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -9,12 +9,12 @@ func VMSpecSetupUEFISettings(vmSpec *kubevirt.VirtualMachineSpec, secureBoot, tp
|
|||||||
firmware := &kubevirt.Firmware{
|
firmware := &kubevirt.Firmware{
|
||||||
Bootloader: &kubevirt.Bootloader{
|
Bootloader: &kubevirt.Bootloader{
|
||||||
EFI: &kubevirt.EFI{
|
EFI: &kubevirt.EFI{
|
||||||
SecureBoot: pointer.Bool(false),
|
SecureBoot: ptr.To(false),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if secureBoot {
|
if secureBoot {
|
||||||
firmware.Bootloader.EFI.SecureBoot = pointer.Bool(true)
|
firmware.Bootloader.EFI.SecureBoot = ptr.To(true)
|
||||||
}
|
}
|
||||||
vmSpec.Template.Spec.Domain.Firmware = firmware
|
vmSpec.Template.Spec.Domain.Firmware = firmware
|
||||||
if tpm {
|
if tpm {
|
||||||
@ -22,7 +22,7 @@ func VMSpecSetupUEFISettings(vmSpec *kubevirt.VirtualMachineSpec, secureBoot, tp
|
|||||||
}
|
}
|
||||||
if secureBoot || tpm {
|
if secureBoot || tpm {
|
||||||
vmSpec.Template.Spec.Domain.Features.SMM = &kubevirt.FeatureState{
|
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"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
|
||||||
"k8s.io/utils/ptr"
|
"k8s.io/utils/ptr"
|
||||||
kubevirt "kubevirt.io/api/core/v1"
|
kubevirt "kubevirt.io/api/core/v1"
|
||||||
|
|
||||||
@ -253,8 +252,8 @@ func (c *Client) ExportVirtualMachine(vm *migration.VirtualMachineImport) error
|
|||||||
"name": vm.Name,
|
"name": vm.Name,
|
||||||
"namespace": vm.Namespace,
|
"namespace": vm.Namespace,
|
||||||
"spec.virtualMachineName": vm.Spec.VirtualMachineName,
|
"spec.virtualMachineName": vm.Spec.VirtualMachineName,
|
||||||
"snapshot.id": ptr.Deref[snapshots.Snapshot](snapshot, snapshots.Snapshot{}).ID,
|
"snapshot.id": ptr.Deref(snapshot, snapshots.Snapshot{}).ID,
|
||||||
"volume.id": ptr.Deref[volumes.Volume](volume, volumes.Volume{}).ID,
|
"volume.id": ptr.Deref(volume, volumes.Volume{}).ID,
|
||||||
"volumeImage.imageID": volumeImage.ImageID,
|
"volumeImage.imageID": volumeImage.ImageID,
|
||||||
}).Info("Cleaning up resources on OpenStack source")
|
}).Info("Cleaning up resources on OpenStack source")
|
||||||
|
|
||||||
@ -555,7 +554,7 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
|
|||||||
},
|
},
|
||||||
Features: &kubevirt.Features{
|
Features: &kubevirt.Features{
|
||||||
ACPI: kubevirt.FeatureState{
|
ACPI: kubevirt.FeatureState{
|
||||||
Enabled: pointer.Bool(true),
|
Enabled: ptr.To(true),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/ptr"
|
||||||
kubevirt "kubevirt.io/api/core/v1"
|
kubevirt "kubevirt.io/api/core/v1"
|
||||||
|
|
||||||
migration "github.com/harvester/vm-import-controller/pkg/apis/migration.harvesterhci.io/v1beta1"
|
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{
|
Features: &kubevirt.Features{
|
||||||
ACPI: kubevirt.FeatureState{
|
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))
|
uefi := strings.EqualFold(o.Config.Firmware, string(types.GuestOsDescriptorFirmwareTypeEfi))
|
||||||
secureBoot := false
|
secureBoot := false
|
||||||
if o.Config.BootOptions != nil {
|
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 {
|
if uefi {
|
||||||
source.VMSpecSetupUEFISettings(&vmSpec, secureBoot, tpm)
|
source.VMSpecSetupUEFISettings(&vmSpec, secureBoot, tpm)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
"github.com/vmware/govmomi/vim25/types"
|
"github.com/vmware/govmomi/vim25/types"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/ptr"
|
||||||
kubevirt "kubevirt.io/api/core/v1"
|
kubevirt "kubevirt.io/api/core/v1"
|
||||||
|
|
||||||
migration "github.com/harvester/vm-import-controller/pkg/apis/migration.harvesterhci.io/v1beta1"
|
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),
|
GuestId: string(types.VirtualMachineGuestOsIdentifierOtherGuest64),
|
||||||
Firmware: string(types.GuestOsDescriptorFirmwareTypeEfi),
|
Firmware: string(types.GuestOsDescriptorFirmwareTypeEfi),
|
||||||
BootOptions: &types.VirtualMachineBootOptions{
|
BootOptions: &types.VirtualMachineBootOptions{
|
||||||
EfiSecureBootEnabled: pointer.Bool(true),
|
EfiSecureBootEnabled: ptr.To(true),
|
||||||
},
|
},
|
||||||
Files: &types.VirtualMachineFileInfo{
|
Files: &types.VirtualMachineFileInfo{
|
||||||
VmPathName: fmt.Sprintf("[%s] %s", ds.Name(), vm.Spec.VirtualMachineName),
|
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",
|
SourceNetwork: "DVSwitch: fea97929-4b2d-5972-b146-930c6d0b4014",
|
||||||
DestinationNetwork: "pod-network",
|
DestinationNetwork: "pod-network",
|
||||||
NetworkInterfaceModel: pointer.String(migration.NetworkInterfaceModelRtl8139),
|
NetworkInterfaceModel: ptr.To(migration.NetworkInterfaceModelRtl8139),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user