Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit 20f1ffe

Browse files
committed
fix: abstract error messages
Signed-off-by: Chris Privitere <[email protected]>
1 parent 4cdd303 commit 20f1ffe

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

controllers/packetmachine_controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ const (
5353
)
5454

5555
var (
56-
ErrMissingDevice = errors.New("machine does not exist")
57-
ErrFacilityMetroMatch = errors.New("instance facility does not match machine facility")
56+
ErrMissingDevice = errors.New("machine does not exist")
57+
ErrFacilityMatch = errors.New("instance facility does not match machine facility")
58+
ErrMetroMatch = errors.New("instance metro does not match machine metro")
5859
)
5960

6061
// PacketMachineReconciler reconciles a PacketMachine object
@@ -418,11 +419,11 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
418419
// If Metro or Facility has changed in the spec, verify that the facility's metro is compatible with the requested spec change.
419420

420421
if machineScope.PacketMachine.Spec.Facility != "" && machineScope.PacketMachine.Spec.Facility != dev.Facility.Code {
421-
return ctrl.Result{}, fmt.Errorf("%w: %s != %s", ErrFacilityMetroMatch, machineScope.PacketMachine.Spec.Facility, dev.Facility.Code)
422+
return ctrl.Result{}, fmt.Errorf("%w: %s != %s", ErrFacilityMatch, machineScope.PacketMachine.Spec.Facility, dev.Facility.Code)
422423
}
423424

424425
if machineScope.PacketMachine.Spec.Metro != "" && machineScope.PacketMachine.Spec.Metro != dev.Metro.Code {
425-
return ctrl.Result{}, fmt.Errorf("instance metro does not match machine metro %s: %w", machineScope.Name(), err)
426+
return ctrl.Result{}, fmt.Errorf("%w: %s != %s", ErrMetroMatch, machineScope.PacketMachine.Spec.Facility, dev.Facility.Code)
426427
}
427428

428429
return result, nil

0 commit comments

Comments
 (0)