Skip to content

Commit

Permalink
Merge pull request kubevirt#13836 from iholder101/clean/general-clean
Browse files Browse the repository at this point in the history
code clean: remove redundant types in composite literals, redundant type conversions
  • Loading branch information
kubevirt-bot authored Feb 3, 2025
2 parents 20ede2c + 9ce8bdd commit 4360aeb
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions pkg/virt-handler/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ var _ = Describe("Domain informer", func() {
record, exists := ghostRecordGlobalCache["test1-namespace/test1"]
Expect(exists).To(BeTrue())
Expect(string(record.UID)).To(Equal("1234-1"))
Expect(string(record.SocketFile)).To(Equal("somefile1"))
Expect(record.SocketFile).To(Equal("somefile1"))

record, exists = ghostRecordGlobalCache["test2-namespace/test2"]
Expect(exists).To(BeTrue())
Expect(string(record.UID)).To(Equal("1234-2"))
Expect(string(record.SocketFile)).To(Equal("somefile2"))
Expect(record.SocketFile).To(Equal("somefile2"))
})

It("Should delete ghost record from cache and disk", func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/virt-handler/cmd-client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func MarkSocketUnresponsive(socket string) error {
}

func SocketDirectoryOnHost(podUID string) string {
return fmt.Sprintf("/%s/%s/volumes/kubernetes.io~empty-dir/sockets", podsBaseDir, string(podUID))
return fmt.Sprintf("/%s/%s/volumes/kubernetes.io~empty-dir/sockets", podsBaseDir, podUID)
}

func SocketFilePathOnHost(podUID string) string {
Expand Down Expand Up @@ -688,7 +688,7 @@ func (c *VirtLauncherClient) Exec(domainName, command string, args []string, tim
DomainName: domainName,
Command: command,
Args: args,
TimeoutSeconds: int32(timeoutSeconds),
TimeoutSeconds: timeoutSeconds,
}
exitCode := -1
stdOut := ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-handler/cmd-client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var _ = Describe("Virt remote commands", func() {

BeforeEach(func() {
vmi = api.NewMinimalVMI("testvmi")
vmi.UID = types.UID("1234")
vmi.UID = "1234"
vmi.Status = v1.VirtualMachineInstanceStatus{
ActivePods: map[types.UID]string{
types.UID(podUID): host,
Expand Down
14 changes: 7 additions & 7 deletions pkg/virt-handler/device-manager/usb_device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[0]}),
},
},
Expand All @@ -97,7 +97,7 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[1]}),
newPluginDevices(resourceName1, 1, []*USBDevice{usbs[2]}),
},
Expand All @@ -120,7 +120,7 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[0], usbs[1]}),
},
},
Expand All @@ -147,10 +147,10 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[0]}),
},
resourceName2: []*PluginDevices{
resourceName2: {
newPluginDevices(resourceName2, 1, []*USBDevice{usbs[1]}),
newPluginDevices(resourceName2, 2, []*USBDevice{usbs[2]}),
},
Expand Down Expand Up @@ -179,7 +179,7 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[0]}),
},
},
Expand Down Expand Up @@ -210,7 +210,7 @@ var _ = Describe("USB Device", func() {
},
},
map[string][]*PluginDevices{
resourceName1: []*PluginDevices{
resourceName1: {
newPluginDevices(resourceName1, 0, []*USBDevice{usbs[0]}),
},
},
Expand Down
14 changes: 7 additions & 7 deletions pkg/virt-launcher/virtwrap/converter/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ func Convert_v1_Firmware_To_related_apis(vmi *v1.VirtualMachineInstance, domain
if len(firmware.Serial) > 0 {
domain.Spec.SysInfo.System = append(domain.Spec.SysInfo.System, api.Entry{
Name: "serial",
Value: string(firmware.Serial),
Value: firmware.Serial,
})
}

Expand Down Expand Up @@ -1483,23 +1483,23 @@ func Convert_v1_VirtualMachineInstance_To_api_Domain(vmi *v1.VirtualMachineInsta
domain.Spec.SysInfo.Chassis = []api.Entry{
{
Name: "manufacturer",
Value: string(vmi.Spec.Domain.Chassis.Manufacturer),
Value: vmi.Spec.Domain.Chassis.Manufacturer,
},
{
Name: "version",
Value: string(vmi.Spec.Domain.Chassis.Version),
Value: vmi.Spec.Domain.Chassis.Version,
},
{
Name: "serial",
Value: string(vmi.Spec.Domain.Chassis.Serial),
Value: vmi.Spec.Domain.Chassis.Serial,
},
{
Name: "asset",
Value: string(vmi.Spec.Domain.Chassis.Asset),
Value: vmi.Spec.Domain.Chassis.Asset,
},
{
Name: "sku",
Value: string(vmi.Spec.Domain.Chassis.Sku),
Value: vmi.Spec.Domain.Chassis.Sku,
},
}
}
Expand Down Expand Up @@ -2043,7 +2043,7 @@ func domainVCPUTopologyForHotplug(vmi *v1.VirtualMachineInstance, domain *api.Do
// There should not be fewer vCPU than cores and threads within a single socket
isHotpluggable := id >= minEnabledCpuCount
vcpu := api.VCPUsVCPU{
ID: uint32(id),
ID: id,
Enabled: boolToYesNo(&isEnabled, true),
Hotpluggable: boolToYesNo(&isHotpluggable, false),
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/virt-launcher/virtwrap/converter/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ var _ = Describe("Converter", func() {
Expect(domain).ToNot(BeNil())
Expect(domain.Spec.Devices.Interfaces).To(HaveLen(2))
Expect(domain.Spec.Devices.Interfaces[0].BootOrder).NotTo(BeNil())
Expect(domain.Spec.Devices.Interfaces[0].BootOrder.Order).To(Equal(uint(bootOrder)))
Expect(domain.Spec.Devices.Interfaces[0].BootOrder.Order).To(Equal(bootOrder))
Expect(domain.Spec.Devices.Interfaces[1].BootOrder).To(BeNil())
})
It("Should create network configuration for masquerade interface", func() {
Expand Down Expand Up @@ -3395,12 +3395,12 @@ var _ = Describe("SetDriverCacheMode", func() {
Expect(disk.Driver.Cache).To(Equal(expectedCache))
}
},
Entry("detect 'none' with direct io", string(""), string(v1.CacheNone), expectCheckTrue),
Entry("detect 'writethrough' without direct io", string(""), string(v1.CacheWriteThrough), expectCheckFalse),
Entry("fallback to 'writethrough' on error", string(""), string(v1.CacheWriteThrough), expectCheckError),
Entry("detect 'none' with direct io", "", string(v1.CacheNone), expectCheckTrue),
Entry("detect 'writethrough' without direct io", "", string(v1.CacheWriteThrough), expectCheckFalse),
Entry("fallback to 'writethrough' on error", "", string(v1.CacheWriteThrough), expectCheckError),
Entry("keep 'none' with direct io", string(v1.CacheNone), string(v1.CacheNone), expectCheckTrue),
Entry("return error without direct io", string(v1.CacheNone), string(""), expectCheckFalse),
Entry("return error on error", string(v1.CacheNone), string(""), expectCheckError),
Entry("return error without direct io", string(v1.CacheNone), "", expectCheckFalse),
Entry("return error on error", string(v1.CacheNone), "", expectCheckError),
Entry("'writethrough' with direct io", string(v1.CacheWriteThrough), string(v1.CacheWriteThrough), expectCheckTrue),
Entry("'writethrough' without direct io", string(v1.CacheWriteThrough), string(v1.CacheWriteThrough), expectCheckFalse),
Entry("'writethrough' on error", string(v1.CacheWriteThrough), string(v1.CacheWriteThrough), expectCheckError),
Expand Down

0 comments on commit 4360aeb

Please sign in to comment.