roryqi commented on code in PR #10586:
URL: https://github.com/apache/gravitino/pull/10586#discussion_r3042706580
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java:
##########
@@ -186,6 +181,64 @@ public Map<String, String> getCatalogConfigToClient() {
return catalogConfigToClients;
}
+ /**
+ * Builds properties exposed to Iceberg clients via the IRC {@code
/v1/config} defaults.
+ *
+ * <p>For {@link RESTCatalog}, uses {@link RESTCatalog#properties()} so
defaults reflect the
+ * remote catalog's config response merged with client properties (after
REST handshake), not only
+ * static Gravitino catalog configuration.
+ */
+ @VisibleForTesting
+ static Map<String, String> buildCatalogConfigToClients(IcebergConfig config,
Catalog catalog) {
+ Map<String, String> sourceProps;
+ if (catalog instanceof RESTCatalog) {
+ Map<String, String> merged = ((RESTCatalog) catalog).properties();
+ sourceProps = merged != null ? new HashMap<>(merged) : new HashMap<>();
+ } else {
+ sourceProps = new HashMap<>(config.getIcebergCatalogProperties());
+ }
+
+ Map<String, String> filtered =
+ MapUtils.getFilteredMap(sourceProps, key ->
catalogPropertiesToClientKeys.contains(key));
+ filtered = new HashMap<>(filtered);
+ validateAndNormalizeDataAccessProperty(filtered);
+
+ return Collections.unmodifiableMap(filtered);
+ }
+
+ @VisibleForTesting
+ static void validateAndNormalizeDataAccessProperty(Map<String, String>
properties) {
+ String dataAccess =
properties.get(IcebergConstants.ICEBERG_ACCESS_DELEGATION);
+ if (StringUtils.isBlank(dataAccess)) {
+ return;
+ }
+
+ String normalizedDataAccess = dataAccess.toLowerCase(Locale.ROOT);
+ if (!DATA_ACCESS_VENDED_CREDENTIALS.equals(normalizedDataAccess)
+ && !DATA_ACCESS_REMOTE_SIGNING.equals(normalizedDataAccess)) {
+ throw new IllegalArgumentException(
+ "Invalid catalog property '"
+ + IcebergConstants.DATA_ACCESS
+ + "': "
+ + dataAccess
+ + ", supported values are ["
+ + DATA_ACCESS_VENDED_CREDENTIALS
+ + ","
+ + DATA_ACCESS_REMOTE_SIGNING
+ + "]");
+ }
+
+ properties.put(IcebergConstants.DATA_ACCESS, normalizedDataAccess);
+ }
+
+ private static void putIfValuePresent(
Review Comment:
Yes, I should remove this.
--
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]