Skip to content

Commit

Permalink
change the config store access
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-maynard committed Mar 3, 2025
1 parent 8e65bb1 commit 8d3c29d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import jakarta.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.entity.CatalogEntity;

/**
Expand Down Expand Up @@ -117,4 +119,18 @@ public interface PolarisConfigurationStore {
return getConfiguration(ctx, config);
}
}

public static <T> @Nonnull T getConfiguration(PolarisConfiguration<T> configuration) {
CallContext callContext = CallContext.getCurrentContext();
if (callContext == null) {
return configuration.defaultValue;
} else {
return callContext
.getPolarisCallContext()
.getConfigurationStore()
.getConfiguration(
callContext.getPolarisCallContext(),
configuration);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.polaris.core.PolarisConfiguration;
import org.apache.polaris.core.PolarisConfigurationStore;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;

Expand Down Expand Up @@ -73,14 +74,8 @@ public AwsStorageConfigurationInfo(
this.roleARN = roleARN;
this.externalId = externalId;
this.region = region;
CallContext callContext = CallContext.getCurrentContext();
validateMaxAllowedLocations(
callContext
.getPolarisCallContext()
.getConfigurationStore()
.getConfiguration(
callContext.getPolarisCallContext(),
PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
PolarisConfigurationStore.getConfiguration(PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.List;
import java.util.Objects;
import org.apache.polaris.core.PolarisConfiguration;
import org.apache.polaris.core.PolarisConfigurationStore;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;

Expand All @@ -50,14 +51,8 @@ public AzureStorageConfigurationInfo(
@JsonProperty(value = "tenantId", required = true) @Nonnull String tenantId) {
super(StorageType.AZURE, allowedLocations);
this.tenantId = tenantId;
CallContext callContext = CallContext.getCurrentContext();
validateMaxAllowedLocations(
callContext
.getPolarisCallContext()
.getConfigurationStore()
.getConfiguration(
callContext.getPolarisCallContext(),
PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
PolarisConfigurationStore.getConfiguration(PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jakarta.annotation.Nullable;
import java.util.List;
import org.apache.polaris.core.PolarisConfiguration;
import org.apache.polaris.core.PolarisConfigurationStore;
import org.apache.polaris.core.context.CallContext;
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;

Expand All @@ -40,14 +41,8 @@ public GcpStorageConfigurationInfo(
@JsonProperty(value = "allowedLocations", required = true) @Nonnull
List<String> allowedLocations) {
super(StorageType.GCS, allowedLocations);
CallContext callContext = CallContext.getCurrentContext();
validateMaxAllowedLocations(
callContext
.getPolarisCallContext()
.getConfigurationStore()
.getConfiguration(
callContext.getPolarisCallContext(),
PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
PolarisConfigurationStore.getConfiguration(PolarisConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS));
}

@Override
Expand Down

0 comments on commit 8d3c29d

Please sign in to comment.