Skip to content

Commit

Permalink
Fix collision of variable name with imported package name
Browse files Browse the repository at this point in the history
Related to: harvester/harvester#7502

Signed-off-by: Volker Theile <[email protected]>
  • Loading branch information
votdev authored and starbops committed Feb 6, 2025
1 parent 29629c7 commit 01bc900
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/source/openstack/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
return nil, fmt.Errorf("error getting firware settings: %v", err)
}

networks, err := generateNetworkInfo(vmObj.Addresses)
networkInfos, err := generateNetworkInfo(vmObj.Addresses)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -451,7 +451,7 @@ func (c *Client) GenerateVirtualMachine(vm *migration.VirtualMachineImport) (*ku
},
}

mappedNetwork := mapNetworkCards(networks, vm.Spec.Mapping)
mappedNetwork := mapNetworkCards(networkInfos, vm.Spec.Mapping)
networkConfig := make([]kubevirt.Network, 0, len(mappedNetwork))
for i, v := range mappedNetwork {
networkConfig = append(networkConfig, kubevirt.Network{
Expand Down Expand Up @@ -700,7 +700,7 @@ func (c *Client) ImageFirmwareSettings(instance *servers.Server) (bool, bool, bo
}

func generateNetworkInfo(info map[string]interface{}) ([]networkInfo, error) {
networks := make([]networkInfo, 0)
networkInfos := make([]networkInfo, 0)
uniqueNetworks := make([]networkInfo, 0)
for network, values := range info {
valArr, ok := values.([]interface{})
Expand All @@ -712,7 +712,7 @@ func generateNetworkInfo(info map[string]interface{}) ([]networkInfo, error) {
if !ok {
return nil, fmt.Errorf("error asserting network array element into map[string]string")
}
networks = append(networks, networkInfo{
networkInfos = append(networkInfos, networkInfo{
NetworkName: network,
MAC: valMap["OS-EXT-IPS-MAC:mac_addr"].(string),
})
Expand All @@ -721,7 +721,7 @@ func generateNetworkInfo(info map[string]interface{}) ([]networkInfo, error) {
// in case of interfaces with ipv6 and ipv4 addresses they are reported twice, so we need to dedup them
// based on a mac address
networksMap := make(map[string]networkInfo)
for _, v := range networks {
for _, v := range networkInfos {
networksMap[v.MAC] = v
}

Expand Down

0 comments on commit 01bc900

Please sign in to comment.