Skip to content

Commit

Permalink
Merge pull request #15844 from mitake/style
Browse files Browse the repository at this point in the history
server/etcdserver: swap order of return types
  • Loading branch information
ahrtr authored May 8, 2023
2 parents 3024d94 + a0cffb6 commit b7ad038
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions server/etcdserver/v3_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,29 +317,29 @@ func (s *EtcdServer) LeaseRenew(ctx context.Context, id lease.LeaseID) (int64, e
return -1, errors.ErrCanceled
}

func (s *EtcdServer) checkLeaseTimeToLive(ctx context.Context, leaseID lease.LeaseID) (error, uint64) {
func (s *EtcdServer) checkLeaseTimeToLive(ctx context.Context, leaseID lease.LeaseID) (uint64, error) {
rev := s.AuthStore().Revision()
if !s.AuthStore().IsAuthEnabled() {
return nil, rev
return rev, nil
}
authInfo, err := s.AuthInfoFromCtx(ctx)
if err != nil {
return err, rev
return rev, err
}
if authInfo == nil {
return auth.ErrUserEmpty, rev
return rev, auth.ErrUserEmpty
}

l := s.lessor.Lookup(leaseID)
if l != nil {
for _, key := range l.Keys() {
if err := s.AuthStore().IsRangePermitted(authInfo, []byte(key), []byte{}); err != nil {
return err, 0
return 0, err
}
}
}

return nil, rev
return rev, nil
}

func (s *EtcdServer) leaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveRequest) (*pb.LeaseTimeToLiveResponse, error) {
Expand Down Expand Up @@ -397,7 +397,7 @@ func (s *EtcdServer) LeaseTimeToLive(ctx context.Context, r *pb.LeaseTimeToLiveR
var err error
if r.Keys {
// check RBAC permission only if Keys is true
err, rev = s.checkLeaseTimeToLive(ctx, lease.LeaseID(r.ID))
rev, err = s.checkLeaseTimeToLive(ctx, lease.LeaseID(r.ID))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b7ad038

Please sign in to comment.