Add nil checks
Signed-off-by: darshanime <deathbullet@gmail.com>
This commit is contained in:
parent
c8a2ffdb72
commit
898afa2fd9
|
@ -452,6 +452,7 @@ func mapFromVM(vm compute.VirtualMachine) virtualMachine {
|
||||||
osType := string(vm.StorageProfile.OsDisk.OsType)
|
osType := string(vm.StorageProfile.OsDisk.OsType)
|
||||||
tags := map[string]*string{}
|
tags := map[string]*string{}
|
||||||
networkInterfaces := []string{}
|
networkInterfaces := []string{}
|
||||||
|
var computerName string
|
||||||
|
|
||||||
if vm.Tags != nil {
|
if vm.Tags != nil {
|
||||||
tags = vm.Tags
|
tags = vm.Tags
|
||||||
|
@ -463,10 +464,14 @@ func mapFromVM(vm compute.VirtualMachine) virtualMachine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if vm.VirtualMachineProperties != nil && vm.VirtualMachineProperties.OsProfile != nil {
|
||||||
|
computerName = *(vm.VirtualMachineProperties.OsProfile.ComputerName)
|
||||||
|
}
|
||||||
|
|
||||||
return virtualMachine{
|
return virtualMachine{
|
||||||
ID: *(vm.ID),
|
ID: *(vm.ID),
|
||||||
Name: *(vm.Name),
|
Name: *(vm.Name),
|
||||||
ComputerName: *(vm.VirtualMachineProperties.OsProfile.ComputerName),
|
ComputerName: computerName,
|
||||||
Type: *(vm.Type),
|
Type: *(vm.Type),
|
||||||
Location: *(vm.Location),
|
Location: *(vm.Location),
|
||||||
OsType: osType,
|
OsType: osType,
|
||||||
|
@ -480,6 +485,7 @@ func mapFromVMScaleSetVM(vm compute.VirtualMachineScaleSetVM, scaleSetName strin
|
||||||
osType := string(vm.StorageProfile.OsDisk.OsType)
|
osType := string(vm.StorageProfile.OsDisk.OsType)
|
||||||
tags := map[string]*string{}
|
tags := map[string]*string{}
|
||||||
networkInterfaces := []string{}
|
networkInterfaces := []string{}
|
||||||
|
var computerName string
|
||||||
|
|
||||||
if vm.Tags != nil {
|
if vm.Tags != nil {
|
||||||
tags = vm.Tags
|
tags = vm.Tags
|
||||||
|
@ -491,10 +497,14 @@ func mapFromVMScaleSetVM(vm compute.VirtualMachineScaleSetVM, scaleSetName strin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if vm.VirtualMachineScaleSetVMProperties != nil && vm.VirtualMachineScaleSetVMProperties.OsProfile != nil {
|
||||||
|
computerName = *(vm.VirtualMachineScaleSetVMProperties.OsProfile.ComputerName)
|
||||||
|
}
|
||||||
|
|
||||||
return virtualMachine{
|
return virtualMachine{
|
||||||
ID: *(vm.ID),
|
ID: *(vm.ID),
|
||||||
Name: *(vm.Name),
|
Name: *(vm.Name),
|
||||||
ComputerName: *(vm.VirtualMachineScaleSetVMProperties.OsProfile.ComputerName),
|
ComputerName: computerName,
|
||||||
Type: *(vm.Type),
|
Type: *(vm.Type),
|
||||||
Location: *(vm.Location),
|
Location: *(vm.Location),
|
||||||
OsType: osType,
|
OsType: osType,
|
||||||
|
|
Loading…
Reference in New Issue