mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdctl v3: adds the --once option to the lease keep-alive command
Fixes: #8719
This commit is contained in:
parent
f46c063285
commit
cb188d0b26
@ -150,15 +150,21 @@ func leaseListCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
display.Leases(*resp)
|
display.Leases(*resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
leaseKeepAliveOnce bool
|
||||||
|
)
|
||||||
|
|
||||||
// NewLeaseKeepAliveCommand returns the cobra command for "lease keep-alive".
|
// NewLeaseKeepAliveCommand returns the cobra command for "lease keep-alive".
|
||||||
func NewLeaseKeepAliveCommand() *cobra.Command {
|
func NewLeaseKeepAliveCommand() *cobra.Command {
|
||||||
lc := &cobra.Command{
|
lc := &cobra.Command{
|
||||||
Use: "keep-alive <leaseID>",
|
Use: "keep-alive [options] <leaseID>",
|
||||||
Short: "Keeps leases alive (renew)",
|
Short: "Keeps leases alive (renew)",
|
||||||
|
|
||||||
Run: leaseKeepAliveCommandFunc,
|
Run: leaseKeepAliveCommandFunc,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lc.Flags().BoolVar(&leaseKeepAliveOnce, "once", false, "Resets the keep-alive time to its original value and exits immediately")
|
||||||
|
|
||||||
return lc
|
return lc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,11 +175,20 @@ func leaseKeepAliveCommandFunc(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
id := leaseFromArgs(args[0])
|
id := leaseFromArgs(args[0])
|
||||||
|
|
||||||
|
if leaseKeepAliveOnce {
|
||||||
|
respc, kerr := mustClientFromCmd(cmd).KeepAliveOnce(context.TODO(), id)
|
||||||
|
if kerr != nil {
|
||||||
|
ExitWithError(ExitBadConnection, kerr)
|
||||||
|
}
|
||||||
|
display.KeepAlive(*respc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
respc, kerr := mustClientFromCmd(cmd).KeepAlive(context.TODO(), id)
|
respc, kerr := mustClientFromCmd(cmd).KeepAlive(context.TODO(), id)
|
||||||
if kerr != nil {
|
if kerr != nil {
|
||||||
ExitWithError(ExitBadConnection, kerr)
|
ExitWithError(ExitBadConnection, kerr)
|
||||||
}
|
}
|
||||||
|
|
||||||
for resp := range respc {
|
for resp := range respc {
|
||||||
display.KeepAlive(*resp)
|
display.KeepAlive(*resp)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user