Skip to content

Commit

Permalink
[apache#5932] improve(CLI): Fix the CLI delete the anonymous user (ap…
Browse files Browse the repository at this point in the history
…ache#6359)

### What changes were proposed in this pull request?

Fix the CLI  delete the anonymous user
### Why are the changes needed?

Fix: apache#5932 

### Does this PR introduce _any_ user-facing change?

(Please list the user-facing changes introduced by your change,
including
  1. Change in user-facing APIs.
  2. Addition or removal of property keys.)

### How was this patch tested?

local test

```bash
gcli user delete -m demo_metalake --user anonymous
# Can't delete anonymous user. This will cause unexpected behavior.
```

<img width="536" alt="image"
src="https://github.com/user-attachments/assets/479ec7eb-2ad3-42bd-b70a-a6f2ce05f794"
/>
  • Loading branch information
Abyss-lord authored and youngyjd committed Feb 14, 2025
1 parent bc28441 commit 40165c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
public class ErrorMessages {
public static final String CATALOG_EXISTS = "Catalog already exists.";
public static final String COLUMN_EXISTS = "Column already exists.";
public static final String DELETE_ANONYMOUS_USER =
"Can't delete anonymous user. This will cause unexpected behavior.";
public static final String FILESET_EXISTS = "Fileset already exists.";
public static final String GROUP_EXISTS = "Group already exists.";
public static final String METALAKE_EXISTS = "Metalake already exists.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.gravitino.cli.commands;

import org.apache.gravitino.auth.AuthConstants;
import org.apache.gravitino.cli.AreYouSure;
import org.apache.gravitino.cli.ErrorMessages;
import org.apache.gravitino.client.GravitinoClient;
Expand Down Expand Up @@ -53,6 +54,10 @@ public DeleteUser(
public void handle() {
boolean deleted = false;

if (AuthConstants.ANONYMOUS_USER.equalsIgnoreCase(user)) {
exitWithError(ErrorMessages.DELETE_ANONYMOUS_USER);
}

if (!AreYouSure.really(force)) {
return;
}
Expand Down

0 comments on commit 40165c7

Please sign in to comment.