@@ -167,13 +167,13 @@ func (r *MetalStackMachineReconciler) SetupWithManager(mgr ctrl.Manager) error {
167167 Complete (r )
168168}
169169
170- func (r * MetalStackMachineReconciler ) create (ctx context.Context , log logr.Logger , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
170+ func (r * MetalStackMachineReconciler ) create (ctx context.Context , _ logr.Logger , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
171171 helper , err := patch .NewHelper (infraMachine , r .Client )
172172 if err != nil {
173173 return err
174174 }
175175
176- //TODO: Find any existing machine by tag first
176+ // TODO: Find any existing machine by tag first
177177 const TagInfraMachineID = "machine.metal-stack.infrastructure.cluster.x-k8s.io/id"
178178 infraMachineOwnerTag := fmt .Sprintf ("%s=%s" , TagInfraMachineID , infraMachine .GetUID ())
179179
@@ -218,8 +218,8 @@ func (r *MetalStackMachineReconciler) create(ctx context.Context, log logr.Logge
218218 return nil
219219}
220220
221- func (r * MetalStackMachineReconciler ) reconcile (ctx context.Context , log logr.Logger , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
222- _ , err := r .findProviderMachine (ctx , infraMachine , infraCluster )
221+ func (r * MetalStackMachineReconciler ) reconcile (ctx context.Context , _ logr.Logger , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
222+ err := r .findProviderMachine (ctx , infraMachine , infraCluster )
223223 if err != nil && ! errors .Is (err , errProviderMachineNotFound ) {
224224 return err
225225 }
@@ -231,7 +231,7 @@ func (r *MetalStackMachineReconciler) reconcile(ctx context.Context, log logr.Lo
231231}
232232
233233func (r * MetalStackMachineReconciler ) delete (ctx context.Context , log logr.Logger , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
234- _ , err := r .findProviderMachine (ctx , infraMachine , infraCluster )
234+ err := r .findProviderMachine (ctx , infraMachine , infraCluster )
235235 if errors .Is (err , errProviderMachineNotFound ) {
236236 // metal-stack machine already freed
237237 return nil
@@ -248,27 +248,29 @@ func (r *MetalStackMachineReconciler) delete(ctx context.Context, log logr.Logge
248248 return nil
249249}
250250
251- func (r * MetalStackMachineReconciler ) status (ctx context.Context , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
251+ func (r * MetalStackMachineReconciler ) status (_ context.Context , _ * v1alpha1.MetalStackMachine , _ * v1alpha1.MetalStackCluster ) error {
252252 return nil
253253}
254254
255- func (r * MetalStackMachineReconciler ) findProviderMachine (ctx context.Context , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) ( * models. V1MachineResponse , error ) {
255+ func (r * MetalStackMachineReconciler ) findProviderMachine (ctx context.Context , infraMachine * v1alpha1.MetalStackMachine , infraCluster * v1alpha1.MetalStackCluster ) error {
256256 mfr := & models.V1MachineFindRequest {
257257 ID : infraMachine .Spec .ProviderID ,
258258 AllocationProject : infraCluster .Spec .ProjectID ,
259259 Tags : []string {fmt .Sprintf ("%s%s" , tag .ClusterID , infraCluster .GetUID ())},
260260 }
261+
261262 resp , err := r .MetalClient .Machine ().FindMachines (metalmachine .NewFindMachinesParamsWithContext (ctx ).WithBody (mfr ), nil )
262263 if err != nil {
263- return nil , err
264+ return err
264265 }
266+
265267 switch len (resp .Payload ) {
266268 case 0 :
267269 // metal-stack machine already freed
268- return nil , errProviderMachineNotFound
270+ return errProviderMachineNotFound
269271 case 1 :
270- return resp . Payload [ 0 ], nil
272+ return nil
271273 default :
272- return nil , errProviderMachineTooManyFound
274+ return errProviderMachineTooManyFound
273275 }
274276}
0 commit comments