@@ -30,7 +30,6 @@ import (
30
30
apierrors "k8s.io/apimachinery/pkg/api/errors"
31
31
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
32
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
33
- "k8s.io/apimachinery/pkg/runtime"
34
33
"k8s.io/client-go/tools/record"
35
34
utilfeature "k8s.io/component-base/featuregate/testing"
36
35
"k8s.io/utils/ptr"
@@ -56,16 +55,6 @@ import (
56
55
"sigs.k8s.io/cluster-api/util/test/builder"
57
56
)
58
57
59
- type InfrastructureMachineSpec struct {
60
- ProviderID * string `json:"providerID,omitempty"`
61
- }
62
-
63
- type InfrastructureMachine struct {
64
- metav1.TypeMeta `json:",inline"`
65
- metav1.ObjectMeta `json:"metadata,omitempty"`
66
- Spec InfrastructureMachineSpec `json:"spec,omitempty"`
67
- }
68
-
69
58
func TestWatches (t * testing.T ) {
70
59
g := NewWithT (t )
71
60
ns , err := env .CreateNamespace (ctx , "test-machine-watches" )
@@ -2599,7 +2588,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2599
2588
},
2600
2589
},
2601
2590
},
2602
- infraMachine : & InfrastructureMachine {} ,
2591
+ infraMachine : nil ,
2603
2592
expectedError : errNoControlPlaneNodes ,
2604
2593
},
2605
2594
{
@@ -2632,7 +2621,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2632
2621
},
2633
2622
},
2634
2623
},
2635
- infraMachine : & InfrastructureMachine {} ,
2624
+ infraMachine : nil ,
2636
2625
expectedError : errNoControlPlaneNodes ,
2637
2626
},
2638
2627
{
@@ -2663,7 +2652,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2663
2652
},
2664
2653
},
2665
2654
},
2666
- infraMachine : & InfrastructureMachine {} ,
2655
+ infraMachine : nil ,
2667
2656
expectedError : nil ,
2668
2657
},
2669
2658
{
@@ -2677,7 +2666,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2677
2666
},
2678
2667
},
2679
2668
machine : & clusterv1.Machine {},
2680
- infraMachine : & InfrastructureMachine {} ,
2669
+ infraMachine : nil ,
2681
2670
expectedError : errClusterIsBeingDeleted ,
2682
2671
},
2683
2672
{
@@ -2716,7 +2705,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2716
2705
},
2717
2706
},
2718
2707
},
2719
- infraMachine : & InfrastructureMachine {} ,
2708
+ infraMachine : nil ,
2720
2709
expectedError : nil ,
2721
2710
},
2722
2711
{
@@ -2755,7 +2744,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2755
2744
},
2756
2745
},
2757
2746
},
2758
- infraMachine : & InfrastructureMachine {} ,
2747
+ infraMachine : nil ,
2759
2748
expectedError : errControlPlaneIsBeingDeleted ,
2760
2749
},
2761
2750
{
@@ -2794,7 +2783,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2794
2783
},
2795
2784
},
2796
2785
},
2797
- infraMachine : & InfrastructureMachine {} ,
2786
+ infraMachine : nil ,
2798
2787
expectedError : errControlPlaneIsBeingDeleted ,
2799
2788
},
2800
2789
{
@@ -2940,10 +2929,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
2940
2929
ClusterCache : clustercache .NewFakeClusterCache (remoteClient , client .ObjectKeyFromObject (tc .cluster )),
2941
2930
}
2942
2931
2943
- infraMachine , err := infrastructureMachineToUnstructured (tc .infraMachine )
2944
- g .Expect (err ).ToNot (HaveOccurred ())
2945
-
2946
- err = mr .isDeleteNodeAllowed (ctx , tc .cluster , tc .machine , infraMachine )
2932
+ err := mr .isDeleteNodeAllowed (ctx , tc .cluster , tc .machine , tc .infraMachine )
2947
2933
if tc .expectedError == nil {
2948
2934
g .Expect (err ).ToNot (HaveOccurred ())
2949
2935
} else {
@@ -3613,12 +3599,3 @@ func podByNodeName(o client.Object) []string {
3613
3599
3614
3600
return []string {pod .Spec .NodeName }
3615
3601
}
3616
-
3617
- func infrastructureMachineToUnstructured (obj * InfrastructureMachine ) (* unstructured.Unstructured , error ) {
3618
- unstructuredMap , err := runtime .DefaultUnstructuredConverter .ToUnstructured (obj )
3619
- if err != nil {
3620
- return nil , err
3621
- }
3622
- unstructuredObj := & unstructured.Unstructured {Object : unstructuredMap }
3623
- return unstructuredObj , nil
3624
- }
0 commit comments