k3s/vendor/github.com/rancher/kine/pkg/server/compact.go
Darren Shepherd a005219c5b Update vendor
2019-08-22 09:14:47 -07:00

35 lines
900 B
Go

package server
import (
"context"
"github.com/coreos/etcd/etcdserver/etcdserverpb"
)
func isCompact(txn *etcdserverpb.TxnRequest) bool {
return len(txn.Compare) == 1 &&
txn.Compare[0].Target == etcdserverpb.Compare_VERSION &&
txn.Compare[0].Result == etcdserverpb.Compare_EQUAL &&
len(txn.Success) == 1 &&
txn.Success[0].GetRequestPut() != nil &&
len(txn.Failure) == 1 &&
txn.Failure[0].GetRequestRange() != nil &&
string(txn.Compare[0].Key) == "compact_rev_key"
}
func (l *LimitedServer) compact(ctx context.Context) (*etcdserverpb.TxnResponse, error) {
return &etcdserverpb.TxnResponse{
Header: &etcdserverpb.ResponseHeader{},
Succeeded: true,
Responses: []*etcdserverpb.ResponseOp{
{
Response: &etcdserverpb.ResponseOp_ResponsePut{
ResponsePut: &etcdserverpb.PutResponse{
Header: &etcdserverpb.ResponseHeader{},
},
},
},
},
}, nil
}