@@ -48,23 +48,41 @@ func SDKToVMSS(sdkvmss compute.VirtualMachineScaleSet, sdkinstances []compute.Vi
48
48
if len (sdkinstances ) > 0 {
49
49
vmss .Instances = make ([]infrav1exp.VMSSVM , len (sdkinstances ))
50
50
for i , vm := range sdkinstances {
51
- instance := infrav1exp.VMSSVM {
52
- ID : to .String (vm .ID ),
53
- InstanceID : to .String (vm .InstanceID ),
54
- Name : to .String (vm .OsProfile .ComputerName ),
55
- State : infrav1 .VMState (to .String (vm .ProvisioningState )),
56
- }
57
-
58
- if vm .LatestModelApplied != nil {
59
- instance .LatestModelApplied = * vm .LatestModelApplied
60
- }
61
-
62
- if vm .Zones != nil && len (* vm .Zones ) > 0 {
63
- instance .AvailabilityZone = to .StringSlice (vm .Zones )[0 ]
64
- }
65
- vmss .Instances [i ] = instance
51
+ vmss .Instances [i ] = * SDKToVMSSVM (vm )
66
52
}
67
53
}
68
54
69
55
return vmss
70
56
}
57
+
58
+ // SDKToVMSSVM converts an Azure SDK VirtualMachineScaleSetVM into an infrav1exp.VMSSVM
59
+ func SDKToVMSSVM (sdkInstance compute.VirtualMachineScaleSetVM ) * infrav1exp.VMSSVM {
60
+ instance := infrav1exp.VMSSVM {
61
+ ID : to .String (sdkInstance .ID ),
62
+ InstanceID : to .String (sdkInstance .InstanceID ),
63
+ LatestModelApplied : true ,
64
+ }
65
+
66
+ if sdkInstance .VirtualMachineScaleSetVMProperties == nil {
67
+ return & instance
68
+ }
69
+
70
+ instance .State = infrav1 .VMStateCreating
71
+ if sdkInstance .ProvisioningState != nil {
72
+ instance .State = infrav1 .VMState (to .String (sdkInstance .ProvisioningState ))
73
+ }
74
+
75
+ if sdkInstance .OsProfile != nil && sdkInstance .OsProfile .ComputerName != nil {
76
+ instance .Name = * sdkInstance .OsProfile .ComputerName
77
+ }
78
+
79
+ if sdkInstance .LatestModelApplied != nil {
80
+ instance .LatestModelApplied = * sdkInstance .LatestModelApplied
81
+ }
82
+
83
+ if sdkInstance .Zones != nil && len (* sdkInstance .Zones ) > 0 {
84
+ instance .AvailabilityZone = to .StringSlice (sdkInstance .Zones )[0 ]
85
+ }
86
+
87
+ return & instance
88
+ }
0 commit comments