-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What changes were proposed in this pull request? Add support for tags in the CLI. ### Why are the changes needed? To add support for tags in CLI. Fix: # (issue) ### Does this PR introduce _any_ user-facing change? Yes, it expands on the command line and adds new commands dealing with tags. ### How was this patch tested? Compiled locally.
- Loading branch information
1 parent
f3fed4a
commit 73c7863
Showing
22 changed files
with
1,231 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
clients/cli/src/main/java/org/apache/gravitino/cli/commands/CreateTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.cli.commands; | ||
|
||
import org.apache.gravitino.cli.ErrorMessages; | ||
import org.apache.gravitino.client.GravitinoClient; | ||
import org.apache.gravitino.exceptions.NoSuchMetalakeException; | ||
import org.apache.gravitino.exceptions.TagAlreadyExistsException; | ||
|
||
public class CreateTag extends Command { | ||
protected final String metalake; | ||
protected final String tag; | ||
protected final String comment; | ||
|
||
/** | ||
* Create a new tag. | ||
* | ||
* @param url The URL of the Gravitino server. | ||
* @param ignoreVersions If true don't check the client/server versions match. | ||
* @param metalake The name of the metalake. | ||
* @param tag The name of the tag. | ||
* @param comment The comment of the tag. | ||
*/ | ||
public CreateTag( | ||
String url, boolean ignoreVersions, String metalake, String tag, String comment) { | ||
super(url, ignoreVersions); | ||
this.metalake = metalake; | ||
this.tag = tag; | ||
this.comment = comment; | ||
} | ||
|
||
/** Create a new tag. */ | ||
@Override | ||
public void handle() { | ||
try { | ||
GravitinoClient client = buildClient(metalake); | ||
client.createTag(tag, comment, null); | ||
} catch (NoSuchMetalakeException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_METALAKE); | ||
return; | ||
} catch (TagAlreadyExistsException err) { | ||
System.err.println(ErrorMessages.TAG_EXISTS); | ||
return; | ||
} catch (Exception exp) { | ||
System.err.println(exp.getMessage()); | ||
return; | ||
} | ||
|
||
System.out.println(tag + " created"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
clients/cli/src/main/java/org/apache/gravitino/cli/commands/DeleteTag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.gravitino.cli.commands; | ||
|
||
import org.apache.gravitino.cli.ErrorMessages; | ||
import org.apache.gravitino.client.GravitinoClient; | ||
import org.apache.gravitino.exceptions.NoSuchMetalakeException; | ||
import org.apache.gravitino.exceptions.NoSuchTagException; | ||
|
||
public class DeleteTag extends Command { | ||
|
||
protected final String metalake; | ||
protected final String tag; | ||
|
||
/** | ||
* Delete a tag. | ||
* | ||
* @param url The URL of the Gravitino server. | ||
* @param ignoreVersions If true don't check the client/server versions match. | ||
* @param metalake The name of the metalake. | ||
* @param tag The name of the tag. | ||
*/ | ||
public DeleteTag(String url, boolean ignoreVersions, String metalake, String tag) { | ||
super(url, ignoreVersions); | ||
this.metalake = metalake; | ||
this.tag = tag; | ||
} | ||
|
||
/** Delete a catalog. */ | ||
@Override | ||
public void handle() { | ||
boolean deleted = false; | ||
|
||
try { | ||
GravitinoClient client = buildClient(metalake); | ||
deleted = client.deleteTag(tag); | ||
} catch (NoSuchMetalakeException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_METALAKE); | ||
return; | ||
} catch (NoSuchTagException err) { | ||
System.err.println(ErrorMessages.UNKNOWN_TAG); | ||
return; | ||
} catch (Exception exp) { | ||
System.err.println(exp.getMessage()); | ||
return; | ||
} | ||
|
||
if (deleted) { | ||
System.out.println(tag + " deleted."); | ||
} else { | ||
System.out.println(tag + " not deleted."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.