@@ -2645,12 +2645,11 @@ func TestIsSubnetExcluded(t *testing.T) {
26452645 os .Setenv (clusterNameEnvVar , "test-cluster" )
26462646
26472647 tests := []struct {
2648- name string
2649- subnetTags []ec2types.Tag
2650- isPrimarySubnet bool
2651- describeError error
2652- want bool
2653- wantErr bool
2648+ name string
2649+ subnetTags []ec2types.Tag
2650+ describeError error
2651+ want bool
2652+ wantErr bool
26542653 }{
26552654 {
26562655 name : "subnet with tag value 0 - excluded" ,
@@ -2660,9 +2659,8 @@ func TestIsSubnetExcluded(t *testing.T) {
26602659 Value : aws .String ("0" ),
26612660 },
26622661 },
2663- isPrimarySubnet : false ,
2664- want : true ,
2665- wantErr : false ,
2662+ want : true ,
2663+ wantErr : false ,
26662664 },
26672665 {
26682666 name : "subnet with tag value 1 - not excluded" ,
@@ -2672,9 +2670,8 @@ func TestIsSubnetExcluded(t *testing.T) {
26722670 Value : aws .String ("1" ),
26732671 },
26742672 },
2675- isPrimarySubnet : false ,
2676- want : false ,
2677- wantErr : false ,
2673+ want : false ,
2674+ wantErr : false ,
26782675 },
26792676 {
26802677 name : "subnet without tag - not excluded" ,
@@ -2684,12 +2681,11 @@ func TestIsSubnetExcluded(t *testing.T) {
26842681 Value : aws .String ("value" ),
26852682 },
26862683 },
2687- isPrimarySubnet : false ,
2688- want : false ,
2689- wantErr : false ,
2684+ want : false ,
2685+ wantErr : false ,
26902686 },
26912687 {
2692- name : "secondary subnet with different cluster tag - excluded by cluster validation" ,
2688+ name : "subnet with different cluster tag - excluded by cluster validation" ,
26932689 subnetTags : []ec2types.Tag {
26942690 {
26952691 Key : aws .String ("kubernetes.io/role/cni" ),
@@ -2700,12 +2696,11 @@ func TestIsSubnetExcluded(t *testing.T) {
27002696 Value : aws .String ("shared" ),
27012697 },
27022698 },
2703- isPrimarySubnet : false ,
2704- want : true ,
2705- wantErr : false ,
2699+ want : true ,
2700+ wantErr : false ,
27062701 },
27072702 {
2708- name : "secondary subnet with matching cluster tag - not excluded" ,
2703+ name : "subnet with matching cluster tag - not excluded" ,
27092704 subnetTags : []ec2types.Tag {
27102705 {
27112706 Key : aws .String ("kubernetes.io/role/cni" ),
@@ -2716,46 +2711,26 @@ func TestIsSubnetExcluded(t *testing.T) {
27162711 Value : aws .String ("shared" ),
27172712 },
27182713 },
2719- isPrimarySubnet : false ,
2720- want : false ,
2721- wantErr : false ,
2714+ want : false ,
2715+ wantErr : false ,
27222716 },
27232717 {
2724- name : "primary subnet always valid regardless of cluster tag" ,
2725- subnetTags : []ec2types.Tag {
2726- {
2727- Key : aws .String ("kubernetes.io/role/cni" ),
2728- Value : aws .String ("1" ),
2729- },
2730- {
2731- Key : aws .String ("kubernetes.io/cluster/other-cluster" ),
2732- Value : aws .String ("shared" ),
2733- },
2734- },
2735- isPrimarySubnet : true ,
2736- want : false ,
2737- wantErr : false ,
2738- },
2739- {
2740- name : "GetVpcSubnets API error" ,
2741- describeError : errors .New ("API error" ),
2742- isPrimarySubnet : false ,
2743- want : false ,
2744- wantErr : true ,
2718+ name : "GetVpcSubnets API error" ,
2719+ describeError : errors .New ("API error" ),
2720+ want : false ,
2721+ wantErr : true ,
27452722 },
27462723 {
2747- name : "no subnets returned" ,
2748- subnetTags : []ec2types.Tag {},
2749- isPrimarySubnet : false ,
2750- want : false ,
2751- wantErr : false ,
2724+ name : "no subnets returned" ,
2725+ subnetTags : []ec2types.Tag {},
2726+ want : false ,
2727+ wantErr : false ,
27522728 },
27532729 {
2754- name : "subnet not found in VPC - should error" ,
2755- subnetTags : []ec2types.Tag {},
2756- isPrimarySubnet : false ,
2757- want : false ,
2758- wantErr : true ,
2730+ name : "subnet not found in VPC - should error" ,
2731+ subnetTags : []ec2types.Tag {},
2732+ want : false ,
2733+ wantErr : true ,
27592734 },
27602735 }
27612736
@@ -2790,7 +2765,7 @@ func TestIsSubnetExcluded(t *testing.T) {
27902765 mockEC2 .EXPECT ().DescribeSubnets (gomock .Any (), gomock .Any ()).Return (subnetResult , nil )
27912766 }
27922767
2793- got , err := cache .IsSubnetExcluded (context .Background (), subnetID , tt . isPrimarySubnet )
2768+ got , err := cache .IsSubnetExcluded (context .Background (), subnetID )
27942769 if tt .wantErr {
27952770 assert .Error (t , err )
27962771 } else {
@@ -3877,7 +3852,7 @@ func TestDataStoreENISubnetID(t *testing.T) {
38773852
38783853func TestIsPrimaryENI (t * testing.T ) {
38793854 cache := & EC2InstanceMetadataCache {primaryENI : "eni-primary" }
3880-
3855+
38813856 assert .True (t , cache .IsPrimaryENI ("eni-primary" ))
38823857 assert .False (t , cache .IsPrimaryENI ("eni-secondary" ))
38833858 assert .False (t , cache .IsPrimaryENI ("" ))
@@ -3887,7 +3862,7 @@ func TestIsEfaOnlyENI(t *testing.T) {
38873862 cache := & EC2InstanceMetadataCache {
38883863 efaOnlyENIsByNetworkCard : []string {"" , "eni-efa" },
38893864 }
3890-
3865+
38913866 assert .True (t , cache .IsEfaOnlyENI (1 , "eni-efa" ))
38923867 assert .False (t , cache .IsEfaOnlyENI (0 , "eni-efa" ))
38933868 assert .False (t , cache .IsEfaOnlyENI (1 , "eni-other" ))
@@ -3896,7 +3871,7 @@ func TestIsEfaOnlyENI(t *testing.T) {
38963871func TestIsUnmanagedENI (t * testing.T ) {
38973872 cache := & EC2InstanceMetadataCache {unmanagedENIs : StringSet {}}
38983873 cache .unmanagedENIs .Set ([]string {"eni-unmanaged" })
3899-
3874+
39003875 assert .True (t , cache .IsUnmanagedENI ("eni-unmanaged" ))
39013876 assert .False (t , cache .IsUnmanagedENI ("eni-managed" ))
39023877 assert .False (t , cache .IsUnmanagedENI ("" ))
0 commit comments