amdubovoi commented on code in PR #18716:
URL: https://github.com/apache/iceberg/pull/18716#discussion_r4663984465
##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPAuthUtils.java:
##########
@@ -48,7 +62,9 @@ public static OAuth2Credentials
oauth2CredentialsFromGcpProperties(
closeableGroup,
"Must specify a closeable group that handles closure of refresh
handler.");
OAuth2RefreshCredentialsHandler oAuthRefreshHandler =
- OAuth2RefreshCredentialsHandler.create(gcpProperties.properties());
+ null != storagePrefix
Review Comment:
Fixed
##########
gcp/src/main/java/org/apache/iceberg/gcp/gcs/OAuth2RefreshCredentialsHandler.java:
##########
@@ -104,7 +123,18 @@ private void checkCredential(Credential gcsCredential,
String gcsOauth2Token) {
}
public static OAuth2RefreshCredentialsHandler create(Map<String, String>
properties) {
- return new OAuth2RefreshCredentialsHandler(properties);
+ return new OAuth2RefreshCredentialsHandler(properties, null);
+ }
+
+ /**
+ * Creates a handler for the storage client of the given prefix. When the
catalog returns more
+ * than one GCS credential, the handler uses the one with the longest prefix
that the storage
+ * prefix starts with.
+ */
+ public static OAuth2RefreshCredentialsHandler create(
+ Map<String, String> properties, String storagePrefix) {
+ Preconditions.checkArgument(null != storagePrefix, "Invalid storage
prefix: null");
Review Comment:
Fixed
##########
gcp/src/main/java/org/apache/iceberg/gcp/GCPAuthUtils.java:
##########
@@ -32,7 +32,21 @@ private GCPAuthUtils() {}
public static OAuth2Credentials oauth2CredentialsFromGcpProperties(
GCPProperties gcpProperties, CloseableGroup closeableGroup) {
+ return oauth2Credentials(gcpProperties, null, closeableGroup);
+ }
+
+ /**
+ * Creates OAuth2 credentials for the storage client of the given prefix. A
refresh uses the GCS
+ * credential with the longest prefix that the storage prefix starts with.
+ */
+ public static OAuth2Credentials oauth2CredentialsFromGcpProperties(
+ GCPProperties gcpProperties, String storagePrefix, CloseableGroup
closeableGroup) {
+ Preconditions.checkArgument(null != storagePrefix, "Invalid storage
prefix: null");
Review Comment:
Fixed
##########
gcp/src/test/java/org/apache/iceberg/gcp/gcs/TestOAuth2RefreshCredentialsHandler.java:
##########
@@ -316,4 +316,66 @@ public void planIdQueryParamIsSent() {
mockServer.verify(mockRequest, VerificationTimes.exactly(2));
}
+
+ @Test
+ void multipleGcsCredentialsUseLongestPrefixOfStoragePrefix() {
Review Comment:
Fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]