Skip to content

Commit

Permalink
use ptr instead of own implementation
Browse files Browse the repository at this point in the history
Signed-off-by: sivchari <shibuuuu5@gmail.com>
  • Loading branch information
sivchari committed Mar 15, 2024
1 parent 5c205f2 commit e950207
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions errors/pointer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Deprecated: errors returns pointer of type received as input, but it can be satisfied by using ptr package.

Check failure on line 17 in errors/pointer.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: package comment should be of the form "Package errors ..." (revive)

Check warning on line 17 in errors/pointer.go

View workflow job for this annotation

GitHub Actions / lint

package-comments: package comment should be of the form "Package errors ..." (revive)
// It keeps these functions for backward compatibility.
//
// cluster-api no longer uses this package, and it will be removed in the future, so please use the ptr package instead.
package errors

// MachineStatusErrorPtr converts a MachineStatusError to a pointer.
Expand Down
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

0 comments on commit e950207

Please sign in to comment.