mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl: add lease comparison to txn command
This commit is contained in:
parent
52b031cfa2
commit
79660db61b
@ -223,12 +223,13 @@ RPC: Txn
|
||||
#### Input Format
|
||||
```ebnf
|
||||
<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
|
||||
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>) "\n"
|
||||
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>|<CMPLEASE>) "\n"
|
||||
<CMPOP> ::= "<" | "=" | ">"
|
||||
<CMPCREATE> := ("c"|"create")"("<KEY>")" <REVISION>
|
||||
<CMPMOD> ::= ("m"|"mod")"("<KEY>")" <CMPOP> <REVISION>
|
||||
<CMPVAL> ::= ("val"|"value")"("<KEY>")" <CMPOP> <VALUE>
|
||||
<CMPVER> ::= ("ver"|"version")"("<KEY>")" <CMPOP> <VERSION>
|
||||
<CMPLEASE> ::= "lease("<KEY>")" <CMPOP> <LEASE>
|
||||
<THEN> ::= <OP>*
|
||||
<ELSE> ::= <OP>*
|
||||
<OP> ::= ((see put, get, del etcdctl command syntax)) "\n"
|
||||
@ -236,6 +237,7 @@ RPC: Txn
|
||||
<VALUE> ::= (%q formatted string)
|
||||
<REVISION> ::= "\""[0-9]+"\""
|
||||
<VERSION> ::= "\""[0-9]+"\""
|
||||
<LEASE> ::= "\""[0-9]+\""
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
@ -193,6 +194,8 @@ func parseCompare(line string) (*clientv3.Cmp, error) {
|
||||
}
|
||||
case "val", "value":
|
||||
cmp = clientv3.Compare(clientv3.Value(key), op, val)
|
||||
case "lease":
|
||||
cmp = clientv3.Compare(clientv3.Cmp{Target: pb.Compare_LEASE}, op, val)
|
||||
default:
|
||||
return nil, fmt.Errorf("malformed comparison: %s (unknown target %s)", line, target)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user