Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use ptr instead of own implementation #10276

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a deprecation message to each of the individual functions.

The usual form is:

// Deprecated: This function is deprecated and will be removed in an upcoming release of Cluster API.

//
// 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 @@ -254,7 +254,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
Loading