Skip to content

Commit

Permalink
[apache#5831] fix(CLI): Fix CLi gives unexpected output when setting …
Browse files Browse the repository at this point in the history
…a tag

Change the code due to new pr merged.
  • Loading branch information
Abyss-lord committed Dec 19, 2024
1 parent e7f16d3 commit d435355
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,20 +619,35 @@ protected void handleTagCommand() {
if (propertySet != null && valueSet != null) {
newSetTagProperty(url, ignore, metalake, getOneTag(tags), propertySet, valueSet).handle();
} else if (propertySet == null && valueSet == null) {
if (!hasEntity(name)) {
System.err.println(ErrorMessages.MALFORMED_NAME);
return;
}
newTagEntity(url, ignore, metalake, name, tags).handle();
} else {
System.err.println(
"This command cannot be executed. The tag set command only supports configuring tag properties or attaching tags to entities.");
}
break;

case CommandActions.REMOVE:
boolean isTag = line.hasOption(GravitinoOptions.TAG);
if (!isTag) {
boolean forceRemove = line.hasOption(GravitinoOptions.FORCE);
if (!hasEntity(name)) {
System.err.println(ErrorMessages.MALFORMED_NAME);
return;
}
newRemoveAllTags(url, ignore, metalake, name, forceRemove).handle();
} else {
String propertyRemove = line.getOptionValue(GravitinoOptions.PROPERTY);
if (propertyRemove != null) {
newRemoveTagProperty(url, ignore, metalake, getOneTag(tags), propertyRemove).handle();
} else {
if (!hasEntity(name)) {
System.err.println(ErrorMessages.MALFORMED_NAME);
return;
}
newUntagEntity(url, ignore, metalake, name, tags).handle();
}
}
Expand Down Expand Up @@ -664,6 +679,13 @@ private String getOneTag(String[] tags) {
return tags[0];
}

private boolean hasEntity(FullName name) {
// TODO fileset and topic
return !(Objects.isNull(name.getCatalogName())
&& Objects.isNull(name.getSchemaName())
&& Objects.isNull(name.getTableName()));
}

/** Handles the command execution for Roles based on command type and the command line options. */
protected void handleRoleCommand() {
String url = getUrl();
Expand Down

0 comments on commit d435355

Please sign in to comment.