dimas-b commented on code in PR #1068:
URL: https://github.com/apache/polaris/pull/1068#discussion_r1993973984
##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -279,6 +285,15 @@ public Builder setStorageConfigurationInfo(
return this;
}
+ /** Validate the number of allowed locations not exceeding the max value.
*/
+ public void validateMaxAllowedLocations(
+ Collection<String> allowedLocations, int maxAllowedLocations) {
Review Comment:
Since the config accessor for `maxAllowedLocations` is static, why not call
it inside this method as opposed to at call sites?
##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -279,6 +285,15 @@ public Builder setStorageConfigurationInfo(
return this;
}
+ /** Validate the number of allowed locations not exceeding the max value.
*/
+ public void validateMaxAllowedLocations(
+ Collection<String> allowedLocations, int maxAllowedLocations) {
+ if (maxAllowedLocations != -1 && allowedLocations.size() >
maxAllowedLocations) {
+ throw new IllegalArgumentException(
+ "Number of allowed locations exceeds " + maxAllowedLocations);
Review Comment:
nit: why not state the actual number that failed the check? It could be
helpful for users to trouble-shoot issues.
##########
polaris-core/src/main/java/org/apache/polaris/core/storage/gcp/GcpStorageConfigurationInfo.java:
##########
@@ -44,7 +40,9 @@ public GcpStorageConfigurationInfo(
@JsonProperty(value = "allowedLocations", required = true) @Nonnull
List<String> allowedLocations) {
super(StorageType.GCS, allowedLocations);
- validateMaxAllowedLocations(MAX_ALLOWED_LOCATIONS);
+ validateMaxAllowedLocations(
+ PolarisConfigurationStore.getConfiguration(
+ PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
Review Comment:
The latest validation approach LGTM :) thx! Posting a couple of minor
comments separately.
##########
polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java:
##########
@@ -279,6 +285,15 @@ public Builder setStorageConfigurationInfo(
return this;
}
+ /** Validate the number of allowed locations not exceeding the max value.
*/
+ public void validateMaxAllowedLocations(
+ Collection<String> allowedLocations, int maxAllowedLocations) {
+ if (maxAllowedLocations != -1 && allowedLocations.size() >
maxAllowedLocations) {
+ throw new IllegalArgumentException(
+ "Number of allowed locations exceeds " + maxAllowedLocations);
Review Comment:
nit: `Preconditions` supports failure message parameters, IIRC :)
--
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]