Skip to content

Commit

Permalink
chore: replace error equality checking with errors.Is
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Dec 3, 2024
1 parent 941c1e0 commit 2e53a80
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apiserver/leadership.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type leadershipToken struct {
// Check is part of the leadership.Token interface.
func (t leadershipToken) Check() error {
err := t.token.Check()
if errors.Cause(err) == lease.ErrNotHeld {
if errors.Is(err, lease.ErrNotHeld) {
return leadership.NewNotLeaderError(t.unitName, t.applicationName)
}
return errors.Trace(err)
Expand All @@ -51,9 +51,9 @@ type leadershipClaimer struct {
}

// ClaimLeadership is part of the leadership.Claimer interface.
func (m leadershipClaimer) ClaimLeadership(ctx context.Context, applicationName, unitName string, duration time.Duration) error {
err := m.claimer.Claim(applicationName, unitName, duration)
if errors.Cause(err) == lease.ErrClaimDenied {
func (m leadershipClaimer) ClaimLeadership(ctx context.Context, appName, unitName string, duration time.Duration) error {
err := m.claimer.Claim(appName, unitName, duration)
if errors.Is(err, lease.ErrNotHeld) {
return leadership.ErrClaimDenied
}
return errors.Trace(err)
Expand All @@ -62,7 +62,7 @@ func (m leadershipClaimer) ClaimLeadership(ctx context.Context, applicationName,
// BlockUntilLeadershipReleased is part of the leadership.Claimer interface.
func (m leadershipClaimer) BlockUntilLeadershipReleased(ctx context.Context, applicationName string) error {
err := m.claimer.WaitUntilExpired(ctx, applicationName, nil)
if errors.Cause(err) == lease.ErrWaitCancelled {
if errors.Is(err, lease.ErrWaitCancelled) {
return leadership.ErrBlockCancelled
}
return errors.Trace(err)
Expand All @@ -76,7 +76,7 @@ type leadershipRevoker struct {
// RevokeLeadership is part of the leadership.Claimer interface.
func (m leadershipRevoker) RevokeLeadership(applicationName string, unitName unit.Name) error {
err := m.claimer.Revoke(applicationName, unitName.String())
if errors.Cause(err) == lease.ErrNotHeld {
if errors.Is(err, lease.ErrNotHeld) {
return leadership.ErrClaimNotHeld
}
return errors.Trace(err)
Expand Down

0 comments on commit 2e53a80

Please sign in to comment.