Skip to content
Draft
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
4 changes: 2 additions & 2 deletions auth/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
type tokenJWT struct {
lg *zap.Logger
signMethod jwt.SigningMethod
key interface{}
key any
ttl time.Duration
verifyOnly bool
}
Expand All @@ -45,7 +45,7 @@ func (t *tokenJWT) info(ctx context.Context, token string, rev uint64) (*AuthInf
revision uint64
)

parsed, err := jwt.Parse(token, func(token *jwt.Token) (interface{}, error) {
parsed, err := jwt.Parse(token, func(token *jwt.Token) (any, error) {
if token.Method.Alg() != t.signMethod.Alg() {
return nil, errors.New("invalid signing method")
}
Expand Down
8 changes: 4 additions & 4 deletions auth/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (opts *jwtOptions) Parse(optMap map[string]string) error {
}

// Key will parse and return the appropriately typed key for the selected signature method
func (opts *jwtOptions) Key() (interface{}, error) {
func (opts *jwtOptions) Key() (any, error) {
switch opts.SignMethod.(type) {
case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS:
return opts.rsaKey()
Expand All @@ -107,14 +107,14 @@ func (opts *jwtOptions) Key() (interface{}, error) {
}
}

func (opts *jwtOptions) hmacKey() (interface{}, error) {
func (opts *jwtOptions) hmacKey() (any, error) {
if len(opts.PrivateKey) == 0 {
return nil, ErrMissingKey
}
return opts.PrivateKey, nil
}

func (opts *jwtOptions) rsaKey() (interface{}, error) {
func (opts *jwtOptions) rsaKey() (any, error) {
var (
priv *rsa.PrivateKey
pub *rsa.PublicKey
Expand Down Expand Up @@ -152,7 +152,7 @@ func (opts *jwtOptions) rsaKey() (interface{}, error) {
return priv, nil
}

func (opts *jwtOptions) ecKey() (interface{}, error) {
func (opts *jwtOptions) ecKey() (any, error) {
var (
priv *ecdsa.PrivateKey
pub *ecdsa.PublicKey
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (

// oneShotCtxValue is set on a context using WithValue(&oneShotValue) so
// that Do() will not retry a request
oneShotCtxValue interface{}
oneShotCtxValue any
)

var DefaultRequestTimeout = 5 * time.Second
Expand Down
4 changes: 2 additions & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ func (f fakeCancelContext) Done() <-chan struct{} {
d <- struct{}{}
return d
}
func (f fakeCancelContext) Err() error { return errFakeCancelContext }
func (f fakeCancelContext) Value(key interface{}) interface{} { return 1 }
func (f fakeCancelContext) Err() error { return errFakeCancelContext }
func (f fakeCancelContext) Value(key any) any { return 1 }

func withTimeout(parent context.Context, timeout time.Duration) (
ctx context.Context,
Expand Down
6 changes: 3 additions & 3 deletions client/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ func (customNumberDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.Iterator) {
iter.ReadVal(&number)
i64, err := strconv.ParseInt(string(number), 10, 64)
if err == nil {
*(*interface{})(ptr) = i64
*(*any)(ptr) = i64
return
}
f64, err := strconv.ParseFloat(string(number), 64)
if err == nil {
*(*interface{})(ptr) = f64
*(*any)(ptr) = f64
return
}
iter.ReportError("DecodeNumber", err.Error())
default:
*(*interface{})(ptr) = iter.Read()
*(*any)(ptr) = iter.Read()
}
}

Expand Down
6 changes: 3 additions & 3 deletions clientv3/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (

type Cmp pb.Compare

func Compare(cmp Cmp, result string, v interface{}) Cmp {
func Compare(cmp Cmp, result string, v any) Cmp {
var r pb.Compare_CompareResult

switch result {
Expand Down Expand Up @@ -120,7 +120,7 @@ func (cmp Cmp) WithPrefix() Cmp {
}

// mustInt64 panics if val isn't an int or int64. It returns an int64 otherwise.
func mustInt64(val interface{}) int64 {
func mustInt64(val any) int64 {
if v, ok := val.(int64); ok {
return v
}
Expand All @@ -132,7 +132,7 @@ func mustInt64(val interface{}) int64 {

// mustInt64orLeaseID panics if val isn't a LeaseID, int or int64. It returns an
// int64 otherwise.
func mustInt64orLeaseID(val interface{}) int64 {
func mustInt64orLeaseID(val any) int64 {
if v, ok := val.(LeaseID); ok {
return int64(v)
}
Expand Down
32 changes: 16 additions & 16 deletions clientv3/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ func (s *settableLogger) get() grpclog.LoggerV2 {

// implement the grpclog.LoggerV2 interface

func (s *settableLogger) Info(args ...interface{}) { s.get().Info(args...) }
func (s *settableLogger) Infof(format string, args ...interface{}) { s.get().Infof(format, args...) }
func (s *settableLogger) Infoln(args ...interface{}) { s.get().Infoln(args...) }
func (s *settableLogger) Warning(args ...interface{}) { s.get().Warning(args...) }
func (s *settableLogger) Warningf(format string, args ...interface{}) {
func (s *settableLogger) Info(args ...any) { s.get().Info(args...) }
func (s *settableLogger) Infof(format string, args ...any) { s.get().Infof(format, args...) }
func (s *settableLogger) Infoln(args ...any) { s.get().Infoln(args...) }
func (s *settableLogger) Warning(args ...any) { s.get().Warning(args...) }
func (s *settableLogger) Warningf(format string, args ...any) {
s.get().Warningf(format, args...)
}
func (s *settableLogger) Warningln(args ...interface{}) { s.get().Warningln(args...) }
func (s *settableLogger) Error(args ...interface{}) { s.get().Error(args...) }
func (s *settableLogger) Errorf(format string, args ...interface{}) {
func (s *settableLogger) Warningln(args ...any) { s.get().Warningln(args...) }
func (s *settableLogger) Error(args ...any) { s.get().Error(args...) }
func (s *settableLogger) Errorf(format string, args ...any) {
s.get().Errorf(format, args...)
}
func (s *settableLogger) Errorln(args ...interface{}) { s.get().Errorln(args...) }
func (s *settableLogger) Fatal(args ...interface{}) { s.get().Fatal(args...) }
func (s *settableLogger) Fatalf(format string, args ...interface{}) { s.get().Fatalf(format, args...) }
func (s *settableLogger) Fatalln(args ...interface{}) { s.get().Fatalln(args...) }
func (s *settableLogger) Print(args ...interface{}) { s.get().Info(args...) }
func (s *settableLogger) Printf(format string, args ...interface{}) { s.get().Infof(format, args...) }
func (s *settableLogger) Println(args ...interface{}) { s.get().Infoln(args...) }
func (s *settableLogger) V(l int) bool { return s.get().V(l) }
func (s *settableLogger) Errorln(args ...any) { s.get().Errorln(args...) }
func (s *settableLogger) Fatal(args ...any) { s.get().Fatal(args...) }
func (s *settableLogger) Fatalf(format string, args ...any) { s.get().Fatalf(format, args...) }
func (s *settableLogger) Fatalln(args ...any) { s.get().Fatalln(args...) }
func (s *settableLogger) Print(args ...any) { s.get().Info(args...) }
func (s *settableLogger) Printf(format string, args ...any) { s.get().Infof(format, args...) }
func (s *settableLogger) Println(args ...any) { s.get().Infoln(args...) }
func (s *settableLogger) V(l int) bool { return s.get().V(l) }
func (s *settableLogger) Lvl(lvl int) grpclog.LoggerV2 {
s.mu.RLock()
l := s.l
Expand Down
14 changes: 7 additions & 7 deletions clientv3/retry_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
// changed through options (e.g. WithMax) on creation of the interceptor or on call (through grpc.CallOptions).
func (c *Client) unaryClientInterceptor(logger *zap.Logger, optFuncs ...retryOption) grpc.UnaryClientInterceptor {
intOpts := reuseOrNewWithCallOptions(defaultOptions, optFuncs)
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
ctx = withVersion(ctx)
grpcOpts, retryOpts := filterCallOptions(opts)
callOpts := reuseOrNewWithCallOptions(intOpts, retryOpts)
Expand Down Expand Up @@ -138,9 +138,9 @@ func (c *Client) streamClientInterceptor(logger *zap.Logger, optFuncs ...retryOp
type serverStreamingRetryingStream struct {
grpc.ClientStream
client *Client
bufferedSends []interface{} // single message that the client can sen
receivedGood bool // indicates whether any prior receives were successful
wasClosedSend bool // indicates that CloseSend was closed
bufferedSends []any // single message that the client can sen
receivedGood bool // indicates whether any prior receives were successful
wasClosedSend bool // indicates that CloseSend was closed
ctx context.Context
callOpts *options
streamerCall func(ctx context.Context) (grpc.ClientStream, error)
Expand All @@ -159,7 +159,7 @@ func (s *serverStreamingRetryingStream) getStream() grpc.ClientStream {
return s.ClientStream
}

func (s *serverStreamingRetryingStream) SendMsg(m interface{}) error {
func (s *serverStreamingRetryingStream) SendMsg(m any) error {
s.mu.Lock()
s.bufferedSends = append(s.bufferedSends, m)
s.mu.Unlock()
Expand All @@ -181,7 +181,7 @@ func (s *serverStreamingRetryingStream) Trailer() metadata.MD {
return s.getStream().Trailer()
}

func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error {
func (s *serverStreamingRetryingStream) RecvMsg(m any) error {
attemptRetry, lastErr := s.receiveMsgAndIndicateRetry(m)
if !attemptRetry {
return lastErr // success or hard failure
Expand All @@ -208,7 +208,7 @@ func (s *serverStreamingRetryingStream) RecvMsg(m interface{}) error {
return lastErr
}

func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m interface{}) (bool, error) {
func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m any) (bool, error) {
s.mu.RLock()
wasGood := s.receivedGood
s.mu.RUnlock()
Expand Down
4 changes: 2 additions & 2 deletions etcdctl/ctlv3/command/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewPrinter(printerType string, isHex bool) printer {

type printerRPC struct {
printer
p func(interface{})
p func(any)
}

func (p *printerRPC) Del(r v3.DeleteResponse) { p.p((*pb.DeleteRangeResponse)(&r)) }
Expand Down Expand Up @@ -150,7 +150,7 @@ func (p *printerRPC) AuthStatus(r v3.AuthStatusResponse) {
type printerUnsupported struct{ printerRPC }

func newPrinterUnsupported(n string) printer {
f := func(interface{}) {
f := func(any) {
ExitWithError(ExitBadFeature, errors.New(n+" not supported as output format"))
}
return &printerUnsupported{printerRPC{nil, f}}
Expand Down
2 changes: 1 addition & 1 deletion etcdctl/ctlv3/command/printer_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (p *jsonPrinter) EndpointStatus(r []epStatus) { printJSON(r) }
func (p *jsonPrinter) EndpointHashKV(r []epHashKV) { printJSON(r) }
func (p *jsonPrinter) DBStatus(r snapshot.Status) { printJSON(r) }

func printJSON(v interface{}) {
func printJSON(v any) {
b, err := json.Marshal(v)
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion etcdctl/ctlv3/command/printer_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (p *pbPrinter) Watch(r v3.WatchResponse) {
printPB(&wr)
}

func printPB(v interface{}) {
func printPB(v any) {
m, ok := v.(pbMarshal)
if !ok {
ExitWithError(ExitBadFeature, fmt.Errorf("marshal unsupported for type %T (%v)", v, v))
Expand Down
8 changes: 4 additions & 4 deletions etcdserver/api/membership/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func TestClusterAddMember(t *testing.T) {
wactions := []testutil.Action{
{
Name: "Create",
Params: []interface{}{
Params: []any{
path.Join(StoreMembersPrefix, "1", "raftAttributes"),
false,
`{"peerURLs":null}`,
Expand All @@ -514,7 +514,7 @@ func TestClusterAddMemberAsLearner(t *testing.T) {
wactions := []testutil.Action{
{
Name: "Create",
Params: []interface{}{
Params: []any{
path.Join(StoreMembersPrefix, "1", "raftAttributes"),
false,
`{"peerURLs":null,"isLearner":true}`,
Expand Down Expand Up @@ -555,8 +555,8 @@ func TestClusterRemoveMember(t *testing.T) {
c.RemoveMember(1)

wactions := []testutil.Action{
{Name: "Delete", Params: []interface{}{MemberStoreKey(1), true, true}},
{Name: "Create", Params: []interface{}{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}},
{Name: "Delete", Params: []any{MemberStoreKey(1), true, true}},
{Name: "Create", Params: []any{RemovedMemberStoreKey(1), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}}},
}
if !reflect.DeepEqual(st.Action(), wactions) {
t.Errorf("actions = %v, want %v", st.Action(), wactions)
Expand Down
4 changes: 2 additions & 2 deletions etcdserver/api/rafthttp/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (t *respRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)
t.mu.Lock()
defer t.mu.Unlock()
if t.rec != nil {
t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}})
t.rec.Record(testutil.Action{Name: "req", Params: []any{req}})
}
return &http.Response{StatusCode: t.code, Header: t.header, Body: &nopReadCloser{}}, t.err
}
Expand All @@ -288,7 +288,7 @@ type roundTripperRecorder struct {

func (t *roundTripperRecorder) RoundTrip(req *http.Request) (*http.Response, error) {
if t.rec != nil {
t.rec.Record(testutil.Action{Name: "req", Params: []interface{}{req}})
t.rec.Record(testutil.Action{Name: "req", Params: []any{req}})
}
return &http.Response{StatusCode: http.StatusNoContent, Body: &nopReadCloser{}}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion etcdserver/api/v2auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ type Error struct {
func (ae Error) Error() string { return ae.Errmsg }
func (ae Error) HTTPStatus() int { return ae.Status }

func authErr(hs int, s string, v ...interface{}) Error {
func authErr(hs int, s string, v ...any) Error {
return Error{Status: hs, Errmsg: fmt.Sprintf("auth: "+s, v...)}
}

Expand Down
6 changes: 3 additions & 3 deletions etcdserver/api/v2auth/auth_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ func (s *store) requestResource(res string, quorum bool) (etcdserver.Response, e
return s.server.Do(ctx, rr)
}

func (s *store) updateResource(res string, value interface{}) (etcdserver.Response, error) {
func (s *store) updateResource(res string, value any) (etcdserver.Response, error) {
return s.setResource(res, value, true)
}
func (s *store) createResource(res string, value interface{}) (etcdserver.Response, error) {
func (s *store) createResource(res string, value any) (etcdserver.Response, error) {
return s.setResource(res, value, false)
}
func (s *store) setResource(res string, value interface{}, prevexist bool) (etcdserver.Response, error) {
func (s *store) setResource(res string, value any, prevexist bool) (etcdserver.Response, error) {
err := s.ensureAuthDirectories()
if err != nil {
return etcdserver.Response{}, err
Expand Down
20 changes: 10 additions & 10 deletions etcdserver/api/v2http/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,35 @@ type serverRecorder struct {
}

func (s *serverRecorder) Do(_ context.Context, r etcdserverpb.Request) (etcdserver.Response, error) {
s.actions = append(s.actions, action{name: "Do", params: []interface{}{r}})
s.actions = append(s.actions, action{name: "Do", params: []any{r}})
return etcdserver.Response{}, nil
}
func (s *serverRecorder) Process(_ context.Context, m raftpb.Message) error {
s.actions = append(s.actions, action{name: "Process", params: []interface{}{m}})
s.actions = append(s.actions, action{name: "Process", params: []any{m}})
return nil
}
func (s *serverRecorder) AddMember(_ context.Context, m membership.Member) ([]*membership.Member, error) {
s.actions = append(s.actions, action{name: "AddMember", params: []interface{}{m}})
s.actions = append(s.actions, action{name: "AddMember", params: []any{m}})
return nil, nil
}
func (s *serverRecorder) RemoveMember(_ context.Context, id uint64) ([]*membership.Member, error) {
s.actions = append(s.actions, action{name: "RemoveMember", params: []interface{}{id}})
s.actions = append(s.actions, action{name: "RemoveMember", params: []any{id}})
return nil, nil
}

func (s *serverRecorder) UpdateMember(_ context.Context, m membership.Member) ([]*membership.Member, error) {
s.actions = append(s.actions, action{name: "UpdateMember", params: []interface{}{m}})
s.actions = append(s.actions, action{name: "UpdateMember", params: []any{m}})
return nil, nil
}

func (s *serverRecorder) PromoteMember(_ context.Context, id uint64) ([]*membership.Member, error) {
s.actions = append(s.actions, action{name: "PromoteMember", params: []interface{}{id}})
s.actions = append(s.actions, action{name: "PromoteMember", params: []any{id}})
return nil, nil
}

type action struct {
name string
params []interface{}
params []any
}

// flushingRecorder provides a channel to allow users to block until the Recorder is Flushed()
Expand Down Expand Up @@ -810,7 +810,7 @@ func TestServeMembersCreate(t *testing.T) {
},
}

wactions := []action{{name: "AddMember", params: []interface{}{wm}}}
wactions := []action{{name: "AddMember", params: []any{wm}}}
if !reflect.DeepEqual(s.actions, wactions) {
t.Errorf("actions = %+v, want %+v", s.actions, wactions)
}
Expand Down Expand Up @@ -844,7 +844,7 @@ func TestServeMembersDelete(t *testing.T) {
if g != "" {
t.Errorf("got body=%q, want %q", g, "")
}
wactions := []action{{name: "RemoveMember", params: []interface{}{uint64(0xBEEF)}}}
wactions := []action{{name: "RemoveMember", params: []any{uint64(0xBEEF)}}}
if !reflect.DeepEqual(s.actions, wactions) {
t.Errorf("actions = %+v, want %+v", s.actions, wactions)
}
Expand Down Expand Up @@ -887,7 +887,7 @@ func TestServeMembersUpdate(t *testing.T) {
},
}

wactions := []action{{name: "UpdateMember", params: []interface{}{wm}}}
wactions := []action{{name: "UpdateMember", params: []any{wm}}}
if !reflect.DeepEqual(s.actions, wactions) {
t.Errorf("actions = %+v, want %+v", s.actions, wactions)
}
Expand Down
Loading