Browse Source

etcdctl/ctlv3: allow empty key

Fix https://github.com/coreos/etcd/issues/5323.
Gyu-Ho Lee 9 years ago
parent
commit
3ec627d1a8
1 changed files with 9 additions and 1 deletions
  1. 9 1
      etcdctl/ctlv3/command/get_command.go

+ 9 - 1
etcdctl/ctlv3/command/get_command.go

@@ -129,10 +129,18 @@ func getGetOp(cmd *cobra.Command, args []string) (string, []clientv3.OpOption) {
 	opts = append(opts, clientv3.WithSort(sortByTarget, sortByOrder))
 	opts = append(opts, clientv3.WithSort(sortByTarget, sortByOrder))
 
 
 	if getPrefix {
 	if getPrefix {
-		opts = append(opts, clientv3.WithPrefix())
+		if len(key) == 0 {
+			key = "\x00"
+			opts = append(opts, clientv3.WithFromKey())
+		} else {
+			opts = append(opts, clientv3.WithPrefix())
+		}
 	}
 	}
 
 
 	if getFromKey {
 	if getFromKey {
+		if len(key) == 0 {
+			key = "\x00"
+		}
 		opts = append(opts, clientv3.WithFromKey())
 		opts = append(opts, clientv3.WithFromKey())
 	}
 	}