@@ -30,7 +30,6 @@ import (
3030 apierrors "k8s.io/apimachinery/pkg/api/errors"
3131 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3232 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
33- "k8s.io/apimachinery/pkg/runtime"
3433 "k8s.io/client-go/tools/record"
3534 utilfeature "k8s.io/component-base/featuregate/testing"
3635 "k8s.io/utils/ptr"
@@ -56,16 +55,6 @@ import (
5655 "sigs.k8s.io/cluster-api/util/test/builder"
5756)
5857
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-
6958func TestWatches (t * testing.T ) {
7059 g := NewWithT (t )
7160 ns , err := env .CreateNamespace (ctx , "test-machine-watches" )
@@ -2599,7 +2588,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
25992588 },
26002589 },
26012590 },
2602- infraMachine : & InfrastructureMachine {} ,
2591+ infraMachine : nil ,
26032592 expectedError : errNoControlPlaneNodes ,
26042593 },
26052594 {
@@ -2632,7 +2621,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
26322621 },
26332622 },
26342623 },
2635- infraMachine : & InfrastructureMachine {} ,
2624+ infraMachine : nil ,
26362625 expectedError : errNoControlPlaneNodes ,
26372626 },
26382627 {
@@ -2663,7 +2652,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
26632652 },
26642653 },
26652654 },
2666- infraMachine : & InfrastructureMachine {} ,
2655+ infraMachine : nil ,
26672656 expectedError : nil ,
26682657 },
26692658 {
@@ -2677,7 +2666,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
26772666 },
26782667 },
26792668 machine : & clusterv1.Machine {},
2680- infraMachine : & InfrastructureMachine {} ,
2669+ infraMachine : nil ,
26812670 expectedError : errClusterIsBeingDeleted ,
26822671 },
26832672 {
@@ -2716,7 +2705,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
27162705 },
27172706 },
27182707 },
2719- infraMachine : & InfrastructureMachine {} ,
2708+ infraMachine : nil ,
27202709 expectedError : nil ,
27212710 },
27222711 {
@@ -2755,7 +2744,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
27552744 },
27562745 },
27572746 },
2758- infraMachine : & InfrastructureMachine {} ,
2747+ infraMachine : nil ,
27592748 expectedError : errControlPlaneIsBeingDeleted ,
27602749 },
27612750 {
@@ -2794,7 +2783,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
27942783 },
27952784 },
27962785 },
2797- infraMachine : & InfrastructureMachine {} ,
2786+ infraMachine : nil ,
27982787 expectedError : errControlPlaneIsBeingDeleted ,
27992788 },
28002789 {
@@ -2940,10 +2929,7 @@ func TestIsDeleteNodeAllowed(t *testing.T) {
29402929 ClusterCache : clustercache .NewFakeClusterCache (remoteClient , client .ObjectKeyFromObject (tc .cluster )),
29412930 }
29422931
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 )
29472933 if tc .expectedError == nil {
29482934 g .Expect (err ).ToNot (HaveOccurred ())
29492935 } else {
@@ -3613,12 +3599,3 @@ func podByNodeName(o client.Object) []string {
36133599
36143600 return []string {pod .Spec .NodeName }
36153601}
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