@@ -43,7 +43,6 @@ import (
4343 "sigs.k8s.io/cluster-api-provider-azure/azure/services/resourceskus"
4444 "sigs.k8s.io/cluster-api-provider-azure/azure/services/roleassignments"
4545 "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages"
46- "sigs.k8s.io/cluster-api-provider-azure/azure/services/virtualmachineimages/mock_virtualmachineimages"
4746 "sigs.k8s.io/cluster-api-provider-azure/azure/services/vmextensions"
4847)
4948
@@ -1538,7 +1537,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15381537 clusterMock .EXPECT ().SubscriptionID ().AnyTimes ()
15391538 clusterMock .EXPECT ().CloudEnvironment ().AnyTimes ()
15401539 clusterMock .EXPECT ().Token ().Return (& azidentity.DefaultAzureCredential {}).AnyTimes ()
1541- svc := virtualmachineimages.Service {Client : mock_virtualmachineimages . NewMockClient ( mockCtrl ) }
1540+ svc := virtualmachineimages.Service {}
15421541
15431542 tests := []struct {
15441543 name string
@@ -1547,7 +1546,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15471546 expectedErr string
15481547 }{
15491548 {
1550- name : "returns AzureMachine image is found if present in the AzureMachine spec" ,
1549+ name : "returns AzureMachine image if present in the AzureMachine spec" ,
15511550 machineScope : MachineScope {
15521551 AzureMachine : & infrav1.AzureMachine {
15531552 ObjectMeta : metav1.ObjectMeta {
@@ -1566,7 +1565,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15661565 expectedErr : "" ,
15671566 },
15681567 {
1569- name : "if no image is specified and os specified is windows with version below 1.22 , returns windows dockershim image" ,
1568+ name : "if no image is specified and os specified is windows, returns windows containerd image" ,
15701569 machineScope : MachineScope {
15711570 Machine : & clusterv1.Machine {
15721571 ObjectMeta : metav1.ObjectMeta {
@@ -1589,42 +1588,13 @@ func TestMachineScope_GetVMImage(t *testing.T) {
15891588 ClusterScoper : clusterMock ,
15901589 },
15911590 want : func () * infrav1.Image {
1592- image , _ := svc .GetDefaultWindowsImage (context .TODO (), "" , "1.20.1" , "dockershim " , "" )
1591+ image , _ := svc .GetDefaultWindowsImage (context .TODO (), "" , "1.20.1" , "containerd " , "" )
15931592 return image
15941593 }(),
15951594 expectedErr : "" ,
15961595 },
15971596 {
1598- name : "if no image is specified and os specified is windows with version is 1.22+ with no annotation, returns windows containerd image" ,
1599- machineScope : MachineScope {
1600- Machine : & clusterv1.Machine {
1601- ObjectMeta : metav1.ObjectMeta {
1602- Name : "machine-name" ,
1603- },
1604- Spec : clusterv1.MachineSpec {
1605- Version : ptr .To ("1.22.1" ),
1606- },
1607- },
1608- AzureMachine : & infrav1.AzureMachine {
1609- ObjectMeta : metav1.ObjectMeta {
1610- Name : "machine-name" ,
1611- },
1612- Spec : infrav1.AzureMachineSpec {
1613- OSDisk : infrav1.OSDisk {
1614- OSType : azure .WindowsOS ,
1615- },
1616- },
1617- },
1618- ClusterScoper : clusterMock ,
1619- },
1620- want : func () * infrav1.Image {
1621- image , _ := svc .GetDefaultWindowsImage (context .TODO (), "" , "1.22.1" , "containerd" , "" )
1622- return image
1623- }(),
1624- expectedErr : "" ,
1625- },
1626- {
1627- name : "if no image is specified and os specified is windows with version is 1.22+ with annotation dockershim, returns windows dockershim image" ,
1597+ name : "if no image is specified and os specified is windows with annotation dockershim, returns error" ,
16281598 machineScope : MachineScope {
16291599 Machine : & clusterv1.Machine {
16301600 ObjectMeta : metav1.ObjectMeta {
@@ -1653,71 +1623,10 @@ func TestMachineScope_GetVMImage(t *testing.T) {
16531623 image , _ := svc .GetDefaultWindowsImage (context .TODO (), "" , "1.22.1" , "dockershim" , "" )
16541624 return image
16551625 }(),
1656- expectedErr : "" ,
1657- },
1658- {
1659- name : "if no image is specified and os specified is windows with version is less and 1.22 with annotation dockershim, returns windows dockershim image" ,
1660- machineScope : MachineScope {
1661- Machine : & clusterv1.Machine {
1662- ObjectMeta : metav1.ObjectMeta {
1663- Name : "machine-name" ,
1664- },
1665- Spec : clusterv1.MachineSpec {
1666- Version : ptr .To ("1.21.1" ),
1667- },
1668- },
1669- AzureMachine : & infrav1.AzureMachine {
1670- ObjectMeta : metav1.ObjectMeta {
1671- Name : "machine-name" ,
1672- Annotations : map [string ]string {
1673- "runtime" : "dockershim" ,
1674- },
1675- },
1676- Spec : infrav1.AzureMachineSpec {
1677- OSDisk : infrav1.OSDisk {
1678- OSType : azure .WindowsOS ,
1679- },
1680- },
1681- },
1682- ClusterScoper : clusterMock ,
1683- },
1684- want : func () * infrav1.Image {
1685- image , _ := svc .GetDefaultWindowsImage (context .TODO (), "" , "1.21.1" , "dockershim" , "" )
1686- return image
1687- }(),
1688- expectedErr : "" ,
1689- },
1690- {
1691- name : "if no image is specified and os specified is windows with version is less and 1.22 with annotation containerd, returns error" ,
1692- machineScope : MachineScope {
1693- Machine : & clusterv1.Machine {
1694- ObjectMeta : metav1.ObjectMeta {
1695- Name : "machine-name" ,
1696- },
1697- Spec : clusterv1.MachineSpec {
1698- Version : ptr .To ("1.21.1" ),
1699- },
1700- },
1701- AzureMachine : & infrav1.AzureMachine {
1702- ObjectMeta : metav1.ObjectMeta {
1703- Name : "machine-name" ,
1704- Annotations : map [string ]string {
1705- "runtime" : "containerd" ,
1706- },
1707- },
1708- Spec : infrav1.AzureMachineSpec {
1709- OSDisk : infrav1.OSDisk {
1710- OSType : azure .WindowsOS ,
1711- },
1712- },
1713- },
1714- ClusterScoper : clusterMock ,
1715- },
1716- want : nil ,
1717- expectedErr : "containerd image only supported in 1.22+" ,
1626+ expectedErr : "unsupported runtime dockershim" ,
17181627 },
17191628 {
1720- name : "if no image is specified and os specified is windows with windowsServerVersion annotation set to 2019, retrurns 2019 image " ,
1629+ name : "if no image is specified and os specified is windows with windowsServerVersion annotation set to 2019, returns error " ,
17211630 machineScope : MachineScope {
17221631 Machine : & clusterv1.Machine {
17231632 ObjectMeta : metav1.ObjectMeta {
@@ -1799,7 +1708,7 @@ func TestMachineScope_GetVMImage(t *testing.T) {
17991708 ClusterScoper : clusterMock ,
18001709 },
18011710 want : func () * infrav1.Image {
1802- image , _ := svc .GetDefaultUbuntuImage (context .TODO (), "" , "1.20.1" )
1711+ image , _ := svc .GetDefaultLinuxImage (context .TODO (), "" , "1.20.1" )
18031712 return image
18041713 }(),
18051714 expectedErr : "" ,
0 commit comments