mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
28 lines
554 B
Go
28 lines
554 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||
|
)
|
||
|
|
||
|
func (l *LimitedServer) get(ctx context.Context, r *etcdserverpb.RangeRequest) (*RangeResponse, error) {
|
||
|
if r.Limit != 0 {
|
||
|
return nil, fmt.Errorf("invalid combination of rangeEnd and limit, limit should be 0 got %d", r.Limit)
|
||
|
}
|
||
|
|
||
|
rev, kv, err := l.backend.Get(ctx, string(r.Key), r.Revision)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
resp := &RangeResponse{
|
||
|
Header: txnHeader(rev),
|
||
|
}
|
||
|
if kv != nil {
|
||
|
resp.Kvs = []*KeyValue{kv}
|
||
|
}
|
||
|
return resp, nil
|
||
|
}
|