-
Notifications
You must be signed in to change notification settings - Fork 409
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
[#5619] feat(api): supports credential api for Gravitino #5690
Conversation
@jerryshao @yuqi1129 please help to review this, thanks |
/** | ||
* Retrieves an array of {@link Credential} objects based on the specified credential type. | ||
* | ||
* @param credentialType The server will return credentials according to the configuration if |
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'd better give some example value of credentialType
, from your description, I could not infer the possible value of it.
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.
updated
api/src/main/java/org/apache/gravitino/exceptions/CredentialDeserializeException.java
Outdated
Show resolved
Hide resolved
* @throws CredentialDeserializeException If there are problems when deserializing the credential | ||
* in client side. | ||
*/ | ||
Credential[] getCredentials(Optional<String> credentialType) |
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.
So we only need parameter credentialType
to abtain credentails?
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.
yes, is it necessary to add a more complicated parameter like CredentialRequest
which contains credentialType
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.
I see.
* @return An array of {@link Credential} objects. There will be only one credential for one | ||
* credential type. In most cases the array only contains one credential. If the object like | ||
* {@link org.apache.gravitino.file.Fileset} contains multi locations for different storages | ||
* like HDFS, S3, etc. The array will contain multi credentials. The array could be empty if |
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.
- There will be only one credential for one credential type.
- In most cases the array only contains one credential
- If the object like {@link org.apache.gravitino.file.Fileset} contains multi locations for different storages
These three sentences are in conflict with each other.
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.
updated
@jerryshao could you help to review this, thanks |
I'm fine with the current implementation. |
@jerryshao do you have time to review this PR? |
* @throws NoSuchCredentialException If the specified credential type cannot be found in the | ||
* server side. | ||
*/ | ||
Credential[] getCredentials(Optional<String> credentialType) throws NoSuchCredentialException; |
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.
I would suggest using two interfaces:
Credentials[] getCredentials();
Credentials getCredentials(String credentialType)
The second interface can have a default implementation and be implemented based on the first one.
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.
updated
@jerryshao @yuqi1129 , all comments are addressed, please help to review again. |
f6fae1f
to
85a5762
Compare
* | ||
* @return An array of {@link Credential} objects. In most cases the array only contains one | ||
* credential. If the object like {@link org.apache.gravitino.file.Fileset} contains multi | ||
* locations for different storages like HDFS, S3, the array will contain multi credentials. |
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.
Change from "multi" to "multiple" in all the places.
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.
updated
Credential[] getCredentials() throws NoSuchCredentialException; | ||
|
||
/** | ||
* Retrieves an {@link Credential} object based on the specific credential type. |
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.
"... based on the specified credential type."
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.
done
* | ||
* @param credentialType The type of the credential like s3-token, s3-secret-key which defined in | ||
* the specific credentials. | ||
* @return An {@link Credential} object with the specific credential type. |
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.
"... with the specified..."
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.
done
"No credential found for the credential type: %s", credentialType); | ||
} else if (credentials.length > 1) { | ||
throw new IllegalStateException( | ||
"Multi credentials found for the credential type:" + credentialType); |
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 change this multi to multiple.
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.
updated
@FANNG1 can you please update the PR description to reflect your updated API? |
done |
### What changes were proposed in this pull request? This is the first PR of credential vending for Gravitino server to add credential API , please refer to #5682 for the overall workflow. Examples to use the API: ```java Catalog catalog = metalake.loadCatalog(catalogName); Credential[] credentials = catalog.supportsCredentials().getCredentials(); Credential credential = catalog.supportsCredentials().getCredential(“s3-token”); ``` ```java Fileset fileset = catalog.asFilesetCatalog().loadFileset(filesetIdent); Credential[] credentials = fileset.supportsCredentials().getCredentials(); Credential credential = fileset.supportsCredentials().getCredential(“s3-token”); ``` ### Why are the changes needed? Fix: #5619 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? using draft PR to do E2E test
What changes were proposed in this pull request?
This is the first PR of credential vending for Gravitino server to add credential API , please refer to #5682 for the overall workflow. Examples to use the API:
Why are the changes needed?
Fix: #5619
Does this PR introduce any user-facing change?
no
How was this patch tested?
using draft PR to do E2E test