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
|
#### Input Format
|
||||||
```ebnf
|
```ebnf
|
||||||
<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
|
<Txn> ::= <CMP>* "\n" <THEN> "\n" <ELSE> "\n"
|
||||||
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>) "\n"
|
<CMP> ::= (<CMPCREATE>|<CMPMOD>|<CMPVAL>|<CMPVER>|<CMPLEASE>) "\n"
|
||||||
<CMPOP> ::= "<" | "=" | ">"
|
<CMPOP> ::= "<" | "=" | ">"
|
||||||
<CMPCREATE> := ("c"|"create")"("<KEY>")" <REVISION>
|
<CMPCREATE> := ("c"|"create")"("<KEY>")" <REVISION>
|
||||||
<CMPMOD> ::= ("m"|"mod")"("<KEY>")" <CMPOP> <REVISION>
|
<CMPMOD> ::= ("m"|"mod")"("<KEY>")" <CMPOP> <REVISION>
|
||||||
<CMPVAL> ::= ("val"|"value")"("<KEY>")" <CMPOP> <VALUE>
|
<CMPVAL> ::= ("val"|"value")"("<KEY>")" <CMPOP> <VALUE>
|
||||||
<CMPVER> ::= ("ver"|"version")"("<KEY>")" <CMPOP> <VERSION>
|
<CMPVER> ::= ("ver"|"version")"("<KEY>")" <CMPOP> <VERSION>
|
||||||
|
<CMPLEASE> ::= "lease("<KEY>")" <CMPOP> <LEASE>
|
||||||
<THEN> ::= <OP>*
|
<THEN> ::= <OP>*
|
||||||
<ELSE> ::= <OP>*
|
<ELSE> ::= <OP>*
|
||||||
<OP> ::= ((see put, get, del etcdctl command syntax)) "\n"
|
<OP> ::= ((see put, get, del etcdctl command syntax)) "\n"
|
||||||
@ -236,6 +237,7 @@ RPC: Txn
|
|||||||
<VALUE> ::= (%q formatted string)
|
<VALUE> ::= (%q formatted string)
|
||||||
<REVISION> ::= "\""[0-9]+"\""
|
<REVISION> ::= "\""[0-9]+"\""
|
||||||
<VERSION> ::= "\""[0-9]+"\""
|
<VERSION> ::= "\""[0-9]+"\""
|
||||||
|
<LEASE> ::= "\""[0-9]+\""
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Output
|
#### Output
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/coreos/etcd/clientv3"
|
"github.com/coreos/etcd/clientv3"
|
||||||
|
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
@ -193,6 +194,8 @@ func parseCompare(line string) (*clientv3.Cmp, error) {
|
|||||||
}
|
}
|
||||||
case "val", "value":
|
case "val", "value":
|
||||||
cmp = clientv3.Compare(clientv3.Value(key), op, val)
|
cmp = clientv3.Compare(clientv3.Value(key), op, val)
|
||||||
|
case "lease":
|
||||||
|
cmp = clientv3.Compare(clientv3.Cmp{Target: pb.Compare_LEASE}, op, val)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("malformed comparison: %s (unknown target %s)", line, target)
|
return nil, fmt.Errorf("malformed comparison: %s (unknown target %s)", line, target)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user