You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "Abyss-lord (via GitHub)" <gi...@apache.org> on 2025/01/15 04:06:15 UTC
[PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Abyss-lord opened a new pull request, #6240:
URL: https://github.com/apache/gravitino/pull/6240
### What changes were proposed in this pull request?
Add ability to revoke all roles from a user or group in the Gravitino CLI.
1. Add logic to handle the `--all` flag in `UserCommandHandler#handleRevokeCommand`;
2. Add logic to handle the `--all `flag in `GroupCommandHandler#handleRevokeCommand`;
3. Add new `RemoveAllRoles` command to handle user revoke --all and group revoke `--all`;
4. Add unit tests;
### Why are the changes needed?
Fix: #5570
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
UT + local test.
User test.
```bash
# step1: grant roles to testRole
gcli user grant -m demo_metalake --user testRole --role roleA roleB roleC -I
# roleA added to testRole
# roleB added to testRole
# roleC added to testRole
# Add roles roleA, roleB, roleC to user testRole
# step2: get details of testRole
gcli user details -m demo_metalake --user testRole -I
# roleA,roleC,roleB
# step3: revoke all roles from testRole
gcli user revoke -m demo_metalake --user testRole -i --all
# Remove all roles from user testRole
# step4: get details of testRole
gcli user details -m demo_metalake --user testRole -I
# The user has no roles.
# step5: list exists roles
gcli role list -m demo_metalake -I
# admin,roleA,roleB,roleC
```
Group test.
```bash
# step1: grant roles to test_group
gcli group grant -m demo_metalake --group test_group --role roleA roleB roleC -I
# roleA added to test_group
# roleB added to test_group
# roleC added to test_group
# Grant roles roleA, roleB, roleC to group test_group
# step2: get details of test_group
gcli group details -m demo_metalake --group test_group -I
# admin,roleA,roleC,roleB
# step3: revoke all roles from test_group
gcli group revoke -m demo_metalake --group test_group -i --all
# Remove all roles from group test_group
# step4: get details of test_group
gcli group details -m demo_metalake --group test_group -I
# The group has no roles.
# step5: list exists roles
gcli role list -m demo_metalake -I
# admin,roleA,roleB,roleC
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#discussion_r1915928455
##########
clients/cli/src/main/java/org/apache/gravitino/cli/commands/RemoveRoleFromGroup.java:
##########
@@ -50,7 +50,7 @@ public RemoveRoleFromGroup(
this.role = role;
}
- /** Adds a role to a group. */
+ /** Removes a from a group. */
Review Comment:
Removes a role?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2594084347
The code looks fine to me. Can you also update the documentation and help content?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2594277194
> The code looks fine to me. Can you also update the documentation and help content?
@justinmclean I’ve finished updating the code and docs. Please take a look at the PR again when you have time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2591711344
@justinmclean I’ve finished updating the code. Please take a look at the PR again when you have time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean merged PR #6240:
URL: https://github.com/apache/gravitino/pull/6240
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2591603547
@justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2594290052
Looks good, but you also need to update the description of -all in GravitinoOptions. Perhaps something like "on all entities".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#discussion_r1915927622
##########
clients/cli/src/main/java/org/apache/gravitino/cli/GroupCommandHandler.java:
##########
@@ -130,14 +130,23 @@ private void handleDeleteCommand() {
/** Handles the "REVOKE" command. */
private void handleRevokeCommand() {
- String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
- for (String role : revokeRoles) {
+ boolean revokeAll = line.hasOption(GravitinoOptions.ALL);
+ if (revokeAll) {
gravitinoCommandLine
- .newRemoveRoleFromGroup(url, ignore, metalake, group, role)
+ .newRemoveAllRoles(url, ignore, metalake, group, CommandEntities.GROUP)
.validate()
.handle();
+ System.out.printf("Remove all roles from group %s%n", group);
Review Comment:
Should be "Removed"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "tengqm (via GitHub)" <gi...@apache.org>.
tengqm commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2591739580
lgtm
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#discussion_r1915928172
##########
clients/cli/src/main/java/org/apache/gravitino/cli/UserCommandHandler.java:
##########
@@ -150,14 +150,23 @@ private void handleDeleteCommand() {
/** Handles the "REVOKE" command. */
private void handleRevokeCommand() {
- String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
- for (String role : revokeRoles) {
- this.gravitinoCommandLine
- .newRemoveRoleFromUser(this.url, this.ignore, this.metalake, user, role)
+ boolean removeAll = line.hasOption(GravitinoOptions.ALL);
+ if (removeAll) {
+ gravitinoCommandLine
+ .newRemoveAllRoles(url, ignore, metalake, user, CommandEntities.USER)
.validate()
.handle();
+ System.out.printf("Remove all roles from user %s%n", user);
Review Comment:
same here
##########
clients/cli/src/main/java/org/apache/gravitino/cli/UserCommandHandler.java:
##########
@@ -150,14 +150,23 @@ private void handleDeleteCommand() {
/** Handles the "REVOKE" command. */
private void handleRevokeCommand() {
- String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
- for (String role : revokeRoles) {
- this.gravitinoCommandLine
- .newRemoveRoleFromUser(this.url, this.ignore, this.metalake, user, role)
+ boolean removeAll = line.hasOption(GravitinoOptions.ALL);
+ if (removeAll) {
+ gravitinoCommandLine
+ .newRemoveAllRoles(url, ignore, metalake, user, CommandEntities.USER)
.validate()
.handle();
+ System.out.printf("Remove all roles from user %s%n", user);
+ } else {
+ String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
+ for (String role : revokeRoles) {
+ this.gravitinoCommandLine
+ .newRemoveRoleFromUser(this.url, this.ignore, this.metalake, user, role)
+ .validate()
+ .handle();
+ }
+ System.out.printf("Remove roles %s from user %s%n", COMMA_JOINER.join(revokeRoles), user);
Review Comment:
and here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "justinmclean (via GitHub)" <gi...@apache.org>.
justinmclean commented on code in PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#discussion_r1915927932
##########
clients/cli/src/main/java/org/apache/gravitino/cli/GroupCommandHandler.java:
##########
@@ -130,14 +130,23 @@ private void handleDeleteCommand() {
/** Handles the "REVOKE" command. */
private void handleRevokeCommand() {
- String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
- for (String role : revokeRoles) {
+ boolean revokeAll = line.hasOption(GravitinoOptions.ALL);
+ if (revokeAll) {
gravitinoCommandLine
- .newRemoveRoleFromGroup(url, ignore, metalake, group, role)
+ .newRemoveAllRoles(url, ignore, metalake, group, CommandEntities.GROUP)
.validate()
.handle();
+ System.out.printf("Remove all roles from group %s%n", group);
+ } else {
+ String[] revokeRoles = line.getOptionValues(GravitinoOptions.ROLE);
+ for (String role : revokeRoles) {
+ gravitinoCommandLine
+ .newRemoveRoleFromGroup(url, ignore, metalake, group, role)
+ .validate()
+ .handle();
+ }
+ System.out.printf("Remove roles %s from group %s%n", COMMA_JOINER.join(revokeRoles), group);
Review Comment:
Should also be "Removed"
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#5570] improve(CLI): Add the ability to revoke all roles or groups in the Gravitino CLI. [gravitino]
Posted by "Abyss-lord (via GitHub)" <gi...@apache.org>.
Abyss-lord commented on PR #6240:
URL: https://github.com/apache/gravitino/pull/6240#issuecomment-2594303437
> Looks good, but you also need to update the description of -all in GravitinoOptions. Perhaps something like "on all entities".
@justinmclean thank you Justin, I just fix the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org