-
Notifications
You must be signed in to change notification settings - Fork 381
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
[#5057] Added first part of CLI code #5058
Merged
Merged
Changes from 28 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
b5e08c0
Added firest part of CLI code.
justinmclean 655d133
update CLI option with output
justinmclean 4a29c8b
Add missing license header
justinmclean 1b12eff
Add default
justinmclean 75de71e
Spotless on Java 11
justinmclean 5172afa
Ignore warnings in test with Java 11
justinmclean 0dc8856
Disable two tests on JAVA 17
justinmclean 24dee9e
disabling two tests for now
justinmclean 0ddbb7d
fix disabled tests
justinmclean 4b95dd3
Still having issues on Java 17
justinmclean f76fa16
remove two tests as Java 17 is still giving issues
justinmclean 8cbc605
No need to copy CLI for IT tests
justinmclean fa2cdaf
remove unneeded call
justinmclean 68f7fa2
change version command into client and server version commands
justinmclean e2ebb7a
list entities and commands
justinmclean 0e82c8f
Cache the metalake environment variable
justinmclean 7b97750
use libs
justinmclean a562ed7
Merge branch 'main' into CLI
justinmclean d678b99
Trino Connector uses old deprecated CLI
justinmclean 10af3d2
remove duplication and clarify
justinmclean f955db2
use client shadow jar
justinmclean 80aef91
wrong file
justinmclean 6d897c0
new -> 19
justinmclean 76aa1fe
fix example command
justinmclean affd6ad
revert as the suggested name is not value
justinmclean abc2da8
simplify command options
justinmclean 9808022
update command options
justinmclean 423219c
Merge branch 'main' into CLI
justinmclean 954b351
Make executable and runnable from bin directory. update command format.
justinmclean 808fffc
revert back to using two args and fix command format
justinmclean 848a381
remove meatlake form name and add back metalake option
justinmclean 2fe9a80
add Gravitino URL as an environment variable
justinmclean 526d305
update README to mention environment variables
justinmclean d2ded4c
improved description of met lake name and add to options docs
justinmclean cb5a5d7
remove version number from alias
justinmclean 71107fd
order in alphabetical order
justinmclean a6aeb42
add final where needed
justinmclean ce3ddc1
made private
justinmclean 70aaaf9
use Joiner instead of StringBuilder
justinmclean 22ca191
update commands
justinmclean ab52cf2
improve command line error handling
justinmclean bd57944
add executable shell script
justinmclean 445cd41
put back README and make it developer focused
justinmclean 7ea7125
support ignore option to ignore client/server version mismatch
justinmclean 0a8844e
move list commands up one entity
justinmclean c342d7e
add comment
justinmclean d2b28af
no need for class
justinmclean 038e1f6
fix command error handling and unwanted output
justinmclean ce5fa18
remove example scripts
justinmclean 069f425
add CLI documentation
justinmclean 0accd4d
no message
justinmclean File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# 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. | ||
# | ||
|
||
# Some of these examples assume you have the Apache Gravitino playground running. | ||
|
||
alias gcli='java -jar clients/cli/build/libs/gravitino-cli-0.7.0-incubating-SNAPSHOT.jar' | ||
|
||
# No such command | ||
gcli unknown | ||
|
||
# unknown command and entiry | ||
gcli unknown --unknown | ||
|
||
# unknown command | ||
gcli metalake --unknown | ||
|
||
# unknown entity | ||
gcli unknown --list | ||
|
||
# Name not specified | ||
gcli metalake --details | ||
|
||
# Unknown metalake name | ||
gcli metalake --details --name unknown | ||
|
||
# Unknown catalog name | ||
gcli catalog --details --name metalake_demo.unknown | ||
|
||
# Missing catalog name | ||
gcli catalog --details --name metalake_demo |
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,103 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
#!/bin/bash | ||
|
||
# These examples assume you have the Apache Gravitino playground running. | ||
|
||
unset GRAVITINO_METALAKE | ||
alias gcli='java -jar clients/cli/build/libs/gravitino-cli-0.7.0-incubating-SNAPSHOT.jar' | ||
|
||
# display help | ||
gcli --help | ||
|
||
# display version | ||
gcli --version | ||
|
||
# metalake details | ||
gcli --details | ||
|
||
# metalake list | ||
gcli --list | ||
|
||
# list all catalogs in a metalake | ||
gcli metalake --list --name metalake_demo | ||
|
||
# list catalog schema | ||
gcli catalog --list --name metalake_demo.catalog_iceberg | ||
gcli catalog --list --name metalake_demo.catalog_mysql | ||
gcli catalog --list --name metalake_demo.catalog_postgres | ||
gcli catalog --list --name metalake_demo.catalog_hive | ||
|
||
# list catalog details | ||
gcli catalog --details --name metalake_demo.catalog_iceberg | ||
gcli catalog --details --name metalake_demo.catalog_mysql | ||
gcli catalog --details --name metalake_demo.catalog_postgres | ||
gcli catalog --details --name metalake_demo.catalog_hive | ||
|
||
# list schema tables | ||
gcli schema --list --name metalake_demo.catalog_postgres.hr | ||
gcli schema --list --name metalake_demo.catalog_mysql.db | ||
gcli schema --list --name metalake_demo.catalog_hive.sales | ||
|
||
# list schema details | ||
gcli schema --details --name metalake_demo.catalog_postgres.hr | ||
gcli schema --details --name metalake_demo.catalog_mysql.db | ||
gcli schema --details --name metalake_demo.catalog_hive.sales | ||
|
||
# list table details | ||
gcli table --list --name metalake_demo.catalog_postgres.hr.departments | ||
gcli table --list --name metalake_demo.catalog_mysql.db.iceberg_tables | ||
gcli table --list --name metalake_demo.catalog_hive.sales.products | ||
|
||
# Exmaples where metalake is set in an evironment variable | ||
export GRAVITINO_METALAKE=metalake_demo | ||
|
||
# metalake details | ||
gcli metalake --details | ||
|
||
# list all catalogs in a metalake | ||
gcli metalake --list | ||
|
||
# list catalog schema | ||
gcli catalog --list --name catalog_iceberg | ||
gcli catalog --list --name catalog_mysql | ||
gcli catalog --list --name catalog_postgres | ||
gcli catalog --list --name catalog_hive | ||
|
||
# list catalog details | ||
gcli catalog --details --name catalog_iceberg | ||
gcli catalog --details --name catalog_mysql | ||
gcli catalog --details --name catalog_postgres | ||
gcli catalog --details --name catalog_hive | ||
|
||
# list schema tables | ||
gcli schema --list --name catalog_postgres.hr | ||
gcli schema --list --name catalog_mysql.db | ||
gcli schema --list --name catalog_hive.sales | ||
|
||
# list schema details | ||
gcli schema --details --name catalog_postgres.hr | ||
gcli schema --details --name catalog_mysql.db | ||
gcli schema --details --name catalog_hive.sales | ||
|
||
# list table details | ||
gcli table --list --name catalog_postgres.hr.departments | ||
gcli table --list --name catalog_mysql.db.iceberg_tables | ||
gcli table --list --name catalog_hive.sales.products |
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,59 @@ | ||
/* | ||
* 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. | ||
*/ | ||
plugins { | ||
`maven-publish` | ||
id("java") | ||
id("idea") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":clients:client-java")) | ||
implementation(project(":api")) | ||
implementation(project(":common")) | ||
implementation(libs.slf4j.api) | ||
implementation(libs.slf4j.simple) | ||
implementation(libs.commons.cli.new) | ||
justinmclean marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
testImplementation(libs.junit.jupiter.api) | ||
testImplementation(libs.junit.jupiter.params) | ||
testImplementation(libs.mockito.core) | ||
|
||
testRuntimeOnly(libs.junit.jupiter.engine) | ||
} | ||
|
||
tasks.build { | ||
dependsOn("javadoc") | ||
yuqi1129 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
tasks.clean { | ||
delete("target") | ||
delete("tmp") | ||
} | ||
|
||
tasks.jar { | ||
manifest { | ||
attributes["Main-Class"] = "org.apache.gravitino.cli.Main" | ||
} | ||
val dependencies = configurations | ||
.runtimeClasspath | ||
.get() | ||
.map(::zipTree) | ||
from(dependencies) | ||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE | ||
} |
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,135 @@ | ||
<!-- | ||
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. | ||
--> | ||
|
||
# Apache Gravitino CLI | ||
|
||
Apache Gravitino CLI is a command-line tool that interacts with the Gravitino server to manage and query entities like metalakes, catalogs, schemas, and tables. The tool provides options for listing information about Gravitino entities and in future versions support creating, deleting, and updating these entities. | ||
|
||
## Table of Contents | ||
|
||
- [Features](#features) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Commands](#commands) | ||
- [Running Tests](#running-tests) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
|
||
## Features | ||
|
||
- Retrieve server version | ||
- Provide help on usage | ||
- Manage Gravitino entities such as Metalakes, Catalogs, Schemas, and Tables | ||
- List details about Gravitino entities | ||
|
||
## Installation | ||
|
||
### Prerequisites | ||
|
||
Before you can build and run this project, it is suggested you have the following installed: | ||
|
||
- Java 8 or higher | ||
|
||
### Build the Project | ||
|
||
1. Clone the entire Gravitino repository: | ||
|
||
```bash | ||
git clone https://github.com/apache/gravitino | ||
``` | ||
|
||
2. Build the CLI sub-project using Gradle: | ||
|
||
```bash | ||
./gradlew :clients:cli:build | ||
``` | ||
3. Create an alias: | ||
|
||
```bash | ||
alias gcli='java -jar clients/cli/build/libs/gravitino-cli-0.7.0-incubating-SNAPSHOT.jar' | ||
``` | ||
3. Test the command: | ||
```bash | ||
gcli --help | ||
``` | ||
|
||
## Usage | ||
|
||
To run the Gravitino CLI, use the following command structure: | ||
|
||
```bash | ||
usage: gcli [metalake|catalog|schema|table] [list|details|create|delete|update] [options] | ||
Options | ||
-C,--create create an entity | ||
-D,--details list details about an entity | ||
-f,--name <arg> full entity name (dot separated) | ||
-h,--help command help information | ||
-L,--list list entity children | ||
justinmclean marked this conversation as resolved.
Show resolved
Hide resolved
|
||
-r,--server Gravitino server version | ||
-R,--delete delete an entity | ||
-u,--url <arg> Gravitino URL (default: http://localhost:8090) | ||
-U,--update update an entity | ||
-v,--version Gravitino client version | ||
``` | ||
|
||
## Commands | ||
The following commands are available for entity management: | ||
|
||
--list: List available entities | ||
--details: Show detailed information about an entity | ||
--create: Create a new entity | ||
--delete: Delete an existing entity | ||
--update: Update an existing entity | ||
|
||
### Examples | ||
List All Metalakes | ||
|
||
```bash | ||
gcli --list | ||
``` | ||
|
||
Get Details of a Specific Metalake | ||
|
||
```bash | ||
gcli metalake --details -name my-metalake | ||
shaofengshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
List Tables in a Catalog | ||
|
||
```bash | ||
gcli metalake --list -name my-metalake | ||
shaofengshi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
## Running Tests | ||
|
||
This project includes a suite of unit tests to verify its functionality. | ||
|
||
To run the tests, execute the following command: | ||
|
||
```bash | ||
./gradlew :clients:cli:test | ||
``` | ||
|
||
## Contributing | ||
|
||
We welcome contributions to the Gravitino CLI! | ||
|
||
## License | ||
|
||
This project is licensed under the Apache License 2.0. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should use the shadow client jar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mchades I tried doing this but was unable to get it to work. You might have to give me some help here. Given it works without why is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it is probably best to do this in a separate PR, unless you think otherwise.