Skip to content

Commit

Permalink
Merge pull request #10276 from sivchari/use-ptr
Browse files Browse the repository at this point in the history
🐛  Use ptr instead of own implementation
  • Loading branch information
k8s-ci-robot committed Mar 20, 2024
2 parents 6daf4ac + 60d5642 commit a848f4a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions errors/pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ limitations under the License.
package errors

// MachineStatusErrorPtr converts a MachineStatusError to a pointer.
//
// Deprecated: This function is deprecated and will be removed in an upcoming release of Cluster API.
func MachineStatusErrorPtr(v MachineStatusError) *MachineStatusError {
return &v
}

// MachinePoolStatusErrorPtr converts a MachinePoolStatusError to a pointer.
//
// Deprecated: This function is deprecated and will be removed in an upcoming release of Cluster API.
func MachinePoolStatusErrorPtr(v MachinePoolStatusFailure) *MachinePoolStatusFailure {
return &v
}

// ClusterStatusErrorPtr converts a MachineStatusError to a pointer.
//
// Deprecated: This function is deprecated and will be removed in an upcoming release of Cluster API.
func ClusterStatusErrorPtr(v ClusterStatusError) *ClusterStatusError {
return &v
}
2 changes: 1 addition & 1 deletion exp/internal/controllers/machinepool_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (r *MachinePoolReconciler) reconcileInfrastructure(ctx context.Context, clu
if mp.Status.InfrastructureReady {
// Infra object went missing after the machine pool was up and running
log.Error(err, "infrastructure reference has been deleted after being ready, setting failure state")
mp.Status.FailureReason = capierrors.MachinePoolStatusErrorPtr(capierrors.InvalidConfigurationMachinePoolError)
mp.Status.FailureReason = ptr.To(capierrors.InvalidConfigurationMachinePoolError)
mp.Status.FailureMessage = ptr.To(fmt.Sprintf("MachinePool infrastructure resource %v with name %q has been deleted after being ready",
mp.Spec.Template.Spec.InfrastructureRef.GroupVersionKind(), mp.Spec.Template.Spec.InfrastructureRef.Name))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/machine/machine_controller_phases.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (r *Reconciler) reconcileInfrastructure(ctx context.Context, s *scope) (ctr
// Infra object went missing after the machine was up and running
if m.Status.InfrastructureReady {
log.Error(err, "Machine infrastructure reference has been deleted after being ready, setting failure state")
m.Status.FailureReason = capierrors.MachineStatusErrorPtr(capierrors.InvalidConfigurationMachineError)
m.Status.FailureReason = ptr.To(capierrors.InvalidConfigurationMachineError)
m.Status.FailureMessage = ptr.To(fmt.Sprintf("Machine infrastructure resource %v with name %q has been deleted after being ready",
m.Spec.InfrastructureRef.GroupVersionKind(), m.Spec.InfrastructureRef.Name))
return ctrl.Result{}, errors.Errorf("could not find %v %q for Machine %q in namespace %q, requeuing", m.Spec.InfrastructureRef.GroupVersionKind().String(), m.Spec.InfrastructureRef.Name, m.Name, m.Namespace)
Expand Down

0 comments on commit a848f4a

Please sign in to comment.