k3s/vendor/github.com/rancher/kine/pkg/server/get.go

28 lines
547 B
Go
Raw Normal View History

2019-08-22 05:12:46 +00:00
package server
import (
"context"
"fmt"
2019-12-12 01:27:03 +00:00
"go.etcd.io/etcd/etcdserver/etcdserverpb"
2019-08-22 05:12:46 +00:00
)
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
}