etcdctl/ctlv3/command/role_command.go
func roleGrantPermissionCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) < 3 {
		ExitWithError(ExitBadArgs, fmt.Errorf("role grant command requires role name, permission type, and key [endkey] as its argument"))
	}

	perm, err := clientv3.StrToPermissionType(args[1])
	if err != nil {
		ExitWithError(ExitBadArgs, err)
	}

	key, rangeEnd := permRange(args[2:])
	resp, err := mustClientFromCmd(cmd).Auth.RoleGrantPermission(context.TODO(), args[0], key, rangeEnd, perm)
	if err != nil {
		ExitWithError(ExitError, err)
	}

	display.RoleGrantPermission(args[0], *resp)
}
func roleGrantPermissionCommandFunc(cmd *cobra.Command, args []string) {
	if len(args) < 3 {
		ExitWithError(ExitBadArgs, fmt.Errorf("role grant command requires role name, permission type, and key [endkey] as its argument"))
	}

	perm, err := clientv3.StrToPermissionType(args[1])
	if err != nil {
		ExitWithError(ExitBadArgs, err)
	}

	key, rangeEnd := permRange(args[2:])
	resp, err := mustClientFromCmd(cmd).Auth.RoleGrantPermission(context.TODO(), args[0], key, rangeEnd, perm)
	if err != nil {
		ExitWithError(ExitError, err)
	}

	display.RoleGrantPermission(args[0], *resp)
}
func roleGrantPermissionCommandFunc ( cmd * cobra . Command , args [ ] string ) { if len ( args ) < 3 { ExitWithError ( ExitBadArgs , fmt . Errorf ( " " ) ) } perm , err := clientv3 . StrToPermissionType ( args [ 1 ] ) if err != nil { ExitWithError ( ExitBadArgs , err ) } key , rangeEnd := permRange ( args [ 2 : ] ) resp , err := mustClientFromCmd ( cmd ) . Auth . RoleGrantPermission ( context . TODO ( ) , args [ 0 ] , key , rangeEnd , perm ) if err != nil { ExitWithError ( ExitError , err ) } display . RoleGrantPermission ( args [ 0 ] , * resp ) }
// roleGrantPermissionCommandFunc executes the "role grant-permission" command.
roleGrantPermissionCommandFunc executes the role grant - permission command .