Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6123] fix(CLI): Refactor the validation logic of tag and role #6127

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

Abyss-lord
Copy link
Contributor

What changes were proposed in this pull request?

Refactor the validation logic of the Tag and Role, meantime fix the test case.

Why are the changes needed?

Fix: #6123

Does this PR introduce any user-facing change?

No

How was this patch tested?

ut + local test

Role test

gcli role grant -m demo_metalake --role admin
# Missing --privilege option.

gcli role revoke -m demo_metalake --role admin
# Missing --privilege option.

Tag test

gcli tag set -m demo_metalake 
# Missing --name option.

gcli tag set -m demo_metalake  --name catalog.schema.table --property property --tag tagA
# Missing --value option.

gcli tag set -m demo_metalake  --name catalog.schema.table --value value --tag tagA
# Missing --property option.

gcli tag remove -m demo_metalake --tag tagA
# Missing --name option.

gcli tag remove -m demo_metalake
# Missing --name option.

gcli tag delete -m demo_metalake
# Missing --tag option.

gcli tag create -m demo_metalake
# Missing --tag option.

Refactor the validation logic of the Role and fix the test case.
Refactor the validation logic of the Tag and fix the test case.
@Abyss-lord
Copy link
Contributor Author

Hi @justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback.

Copy link
Contributor

@tengqm tengqm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

@@ -736,7 +724,7 @@ protected void handleTagCommand() {
}

private String getOneTag(String[] tags) {
if (tags.length > 1) {
if (tags == null || tags.length > 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is possible for tags to be null at this point, but I guess it doesn't hurt

Copy link
Member

@justinmclean justinmclean left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks

@justinmclean justinmclean merged commit 6ad3d3b into apache:main Jan 7, 2025
27 checks passed
@Abyss-lord Abyss-lord deleted the refactor-tag-role-validation branch January 7, 2025 07:03
Abyss-lord added a commit to Abyss-lord/gravitino that referenced this pull request Jan 9, 2025
…apache#6127)

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

Refactor the validation logic of the Tag and Role, meantime fix the test
case.

### Why are the changes needed?

Fix: apache#6123 

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

No

### How was this patch tested?

ut + local test

**Role test**
```bash
gcli role grant -m demo_metalake --role admin
# Missing --privilege option.

gcli role revoke -m demo_metalake --role admin
# Missing --privilege option.
```

**Tag test**

```bash
gcli tag set -m demo_metalake 
# Missing --name option.

gcli tag set -m demo_metalake  --name catalog.schema.table --property property --tag tagA
# Missing --value option.

gcli tag set -m demo_metalake  --name catalog.schema.table --value value --tag tagA
# Missing --property option.

gcli tag remove -m demo_metalake --tag tagA
# Missing --name option.

gcli tag remove -m demo_metalake
# Missing --name option.

gcli tag delete -m demo_metalake
# Missing --tag option.

gcli tag create -m demo_metalake
# Missing --tag option.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] Refactor the validation logic of tag and role
3 participants