diff --git a/etcdctl/README.md b/etcdctl/README.md index 8111bf30e..7884d53ff 100644 --- a/etcdctl/README.md +++ b/etcdctl/README.md @@ -6,6 +6,24 @@ Make sure to set environment variable `ETCDCTL_API=3`. For etcdctl v2, please ch ## Commands +### VERSION + +Prints the version of etcdctl + +#### Return value + +##### Simple reply + +- Prints etcd version and API version + +#### Examples + +```bash +./etcdctl version +# etcdctl version: 3.1.0-alpha.0+git +# API version: 3.1 +``` + ### PUT [options] \ \ PUT assigns the specified value with the specified key. If key already holds a value, it is overwritten. @@ -918,39 +936,9 @@ The provided transformer should read until EOF and flush the stdout before exiti # finished transforming keys ``` -### AUTH \ +### ROLE \ -`auth enable` activates authentication on an etcd cluster and `auth disable` deactivates. When authentication is enabled, etcd checks all requests for appropriate authorization. - -#### Return value - -##### Simple reply - -- `Authentication Enabled`. Exit code is zero. - -- Error string if AUTH failed. Exit code is non-zero. - -#### Examples - -```bash -./etcdctl user add root -# Password of root:#type password for root -# Type password of root again for confirmation:#re-type password for root -# User root created -./etcdctl user grant-role root root -# Role root is granted to user root -./etcdctl user get root -# User: root -# Roles: root -./etcdctl role add root -# Role root created -./etcdctl role get root -# Role root -# KV Read: -# KV Write: -./etcdctl auth enable -# Authentication Enabled -``` +ROLE is used to specify differnt roles which can be assigned to etcd user(s). ### ROLE ADD \ @@ -971,25 +959,6 @@ The provided transformer should read until EOF and flush the stdout before exiti # Role myrole created ``` -### ROLE DELETE \ - -`role delete` deletes a role. - -#### Return value - -##### Simple reply - -- `Role deleted`. Exit code is zero. - -- Error string if failed. Exit code is non-zero. - -#### Examples - -```bash -./etcdctl --user=root:123 role delete myrole -# Role myrole deleted -``` - ### ROLE GET \ `role get` lists detailed role information. @@ -1013,10 +982,14 @@ The provided transformer should read until EOF and flush the stdout before exiti # foo ``` -### ROLE GRANT-PERMISSION \ \ \ [endkey] +### ROLE GRANT-PERMISSION [options] \ \ \ [endkey] `role grant-permission` grants a key to a role. +#### Options + +- prefix -- grant a prefix permission + #### Return value ##### Simple reply @@ -1051,10 +1024,37 @@ The provided transformer should read until EOF and flush the stdout before exiti # Permission of key foo is revoked from role myrole ``` -### USER ADD \ +### ROLE DELETE \ + +`role delete` deletes a role. + +#### Return value + +##### Simple reply + +- `Role deleted`. Exit code is zero. + +- Error string if failed. Exit code is non-zero. + +#### Examples + +```bash +./etcdctl --user=root:123 role delete myrole +# Role myrole deleted +``` + +### USER \ + +USER provides commands for managing users of etcd. + +### USER ADD \ [options] `user add` creates a user. +#### Options + +- interactive -- Read password from stdin instead of interactive terminal + #### Return value ##### Simple reply @@ -1072,29 +1072,14 @@ The provided transformer should read until EOF and flush the stdout before exiti # User myuser created ``` -### USER DELETE \ - -`user delete` deletes a user. - -#### Return value - -##### Simple reply - -- `User deleted`. Exit code is zero. - -- Error string if failed. Exit code is non-zero. - -#### Examples - -```bash -./etcdctl --user=root:123 user delete myuser -# User myuser deleted -``` - -### USER GET \ +### USER GET \ [options] `user get` lists detailed user information. +#### Options + +- detail -- Show permissions of roles granted to the user + #### Return value ##### Simple reply @@ -1111,7 +1096,7 @@ The provided transformer should read until EOF and flush the stdout before exiti # Roles: ``` -### USER PASSWD \ +### USER PASSWD \ [options] `user passwd` changes a user's password. @@ -1174,11 +1159,118 @@ The provided transformer should read until EOF and flush the stdout before exiti # Role roleA is revoked from user userA ``` +### USER DELETE \ + +`user delete` deletes a user. + +#### Return value + +##### Simple reply + +- `User deleted`. Exit code is zero. + +- Error string if failed. Exit code is non-zero. + +#### Examples + +```bash +./etcdctl --user=root:123 user delete myuser +# User myuser deleted +``` + +### AUTH \ + +`auth enable` activates authentication on an etcd cluster and `auth disable` deactivates. When authentication is enabled, etcd checks all requests for appropriate authorization. + +#### Return value + +##### Simple reply + +- `Authentication Enabled`. Exit code is zero. + +- Error string if AUTH failed. Exit code is non-zero. + +#### Examples + +```bash +./etcdctl user add root +# Password of root:#type password for root +# Type password of root again for confirmation:#re-type password for root +# User root created +./etcdctl user grant-role root root +# Role root is granted to user root +./etcdctl user get root +# User: root +# Roles: root +./etcdctl role add root +# Role root created +./etcdctl role get root +# Role root +# KV Read: +# KV Write: +./etcdctl auth enable +# Authentication Enabled +``` + +## ALARM \ + +Provides alarm related commands + +### ALARM DISARM + +`alarm disarm` Disarms all alarms + +#### Return value + +##### Simple reply + +- `alarm:` if alarm is present + +- `` if alarm is not present + +#### Examples + +```bash +./etcdctl alarm disarm +``` + +If NOSPACE alarm is present: + +```bash +./etcdctl alarm disarm +# alarm:NOSPACE +``` + +### ALARM LIST + +`alarm list` Lists all alarms + +#### Return value + +##### Simple reply + +- `alarm:` if alarm is present + +- `` if alarm is not present + +#### Examples + +```bash +./etcdctl alarm list +``` + +If NOSPACE alarm is present: + +```bash +./etcdctl alarm list +# alarm:NOSPACE +``` + ## Notes - JSON encoding for keys and values uses base64 since they are byte strings. - +- [etcdrpc]: ../etcdserver/etcdserverpb/rpc.proto [storagerpc]: ../mvcc/mvccpb/kv.proto [member_list_rpc]: ../etcdserver/etcdserverpb/rpc.proto#L493-L497 diff --git a/etcdctl/ctlv3/command/role_command.go b/etcdctl/ctlv3/command/role_command.go index a13809c1c..46234e58f 100644 --- a/etcdctl/ctlv3/command/role_command.go +++ b/etcdctl/ctlv3/command/role_command.go @@ -78,7 +78,7 @@ func newRoleListCommand() *cobra.Command { func newRoleGrantPermissionCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "grant-permission [endkey]", + Use: "grant-permission [options] [endkey]", Short: "Grants a key to a role", Run: roleGrantPermissionCommandFunc, } diff --git a/etcdctl/ctlv3/command/user_command.go b/etcdctl/ctlv3/command/user_command.go index d06dd1be0..fb09a27b9 100644 --- a/etcdctl/ctlv3/command/user_command.go +++ b/etcdctl/ctlv3/command/user_command.go @@ -51,7 +51,7 @@ var ( func newUserAddCommand() *cobra.Command { cmd := cobra.Command{ - Use: "add ", + Use: "add [options]", Short: "Adds a new user", Run: userAddCommandFunc, } @@ -71,7 +71,7 @@ func newUserDeleteCommand() *cobra.Command { func newUserGetCommand() *cobra.Command { cmd := cobra.Command{ - Use: "get ", + Use: "get [options]", Short: "Gets detailed information of a user", Run: userGetCommandFunc, } @@ -91,7 +91,7 @@ func newUserListCommand() *cobra.Command { func newUserChangePasswordCommand() *cobra.Command { cmd := cobra.Command{ - Use: "passwd ", + Use: "passwd [options]", Short: "Changes password of user", Run: userChangePasswordCommandFunc, }