etcdctl/ctlv2: use latest Action interface
This commit is contained in:
@ -92,7 +92,7 @@ func mustNewAuthRoleAPI(c *cli.Context) client.AuthRoleAPI {
|
||||
return client.NewAuthRoleAPI(hc)
|
||||
}
|
||||
|
||||
func actionRoleList(c *cli.Context) {
|
||||
func actionRoleList(c *cli.Context) error {
|
||||
if len(c.Args()) != 0 {
|
||||
fmt.Fprintln(os.Stderr, "No arguments accepted")
|
||||
os.Exit(1)
|
||||
@ -109,9 +109,11 @@ func actionRoleList(c *cli.Context) {
|
||||
for _, role := range roles {
|
||||
fmt.Printf("%s\n", role)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func actionRoleAdd(c *cli.Context) {
|
||||
func actionRoleAdd(c *cli.Context) error {
|
||||
api, role := mustRoleAPIAndName(c)
|
||||
ctx, cancel := contextWithTotalTimeout(c)
|
||||
defer cancel()
|
||||
@ -128,9 +130,10 @@ func actionRoleAdd(c *cli.Context) {
|
||||
}
|
||||
|
||||
fmt.Printf("Role %s created\n", role)
|
||||
return nil
|
||||
}
|
||||
|
||||
func actionRoleRemove(c *cli.Context) {
|
||||
func actionRoleRemove(c *cli.Context) error {
|
||||
api, role := mustRoleAPIAndName(c)
|
||||
ctx, cancel := contextWithTotalTimeout(c)
|
||||
err := api.RemoveRole(ctx, role)
|
||||
@ -141,14 +144,17 @@ func actionRoleRemove(c *cli.Context) {
|
||||
}
|
||||
|
||||
fmt.Printf("Role %s removed\n", role)
|
||||
return nil
|
||||
}
|
||||
|
||||
func actionRoleGrant(c *cli.Context) {
|
||||
func actionRoleGrant(c *cli.Context) error {
|
||||
roleGrantRevoke(c, true)
|
||||
return nil
|
||||
}
|
||||
|
||||
func actionRoleRevoke(c *cli.Context) {
|
||||
func actionRoleRevoke(c *cli.Context) error {
|
||||
roleGrantRevoke(c, false)
|
||||
return nil
|
||||
}
|
||||
|
||||
func roleGrantRevoke(c *cli.Context, grant bool) {
|
||||
@ -214,7 +220,7 @@ func roleGrantRevoke(c *cli.Context, grant bool) {
|
||||
fmt.Printf("Role %s updated\n", role)
|
||||
}
|
||||
|
||||
func actionRoleGet(c *cli.Context) {
|
||||
func actionRoleGet(c *cli.Context) error {
|
||||
api, rolename := mustRoleAPIAndName(c)
|
||||
|
||||
ctx, cancel := contextWithTotalTimeout(c)
|
||||
@ -233,6 +239,7 @@ func actionRoleGet(c *cli.Context) {
|
||||
for _, v := range role.Permissions.KV.Write {
|
||||
fmt.Printf("\t%s\n", v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func mustRoleAPIAndName(c *cli.Context) (client.AuthRoleAPI, string) {
|
||||
|
Reference in New Issue
Block a user