Skip to content

Commit fa3e82a

Browse files
committed
review: rename to StorageAccessProperty
1 parent 60c2a14 commit fa3e82a

File tree

16 files changed

+138
-155
lines changed

16 files changed

+138
-155
lines changed

polaris-core/src/main/java/org/apache/polaris/core/persistence/AtomicOperationMetaStoreManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@
6666
import org.apache.polaris.core.policy.PolicyEntity;
6767
import org.apache.polaris.core.policy.PolicyMappingUtil;
6868
import org.apache.polaris.core.policy.PolicyType;
69-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
7069
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
7170
import org.apache.polaris.core.storage.PolarisStorageIntegration;
71+
import org.apache.polaris.core.storage.StorageAccessProperty;
7272
import org.slf4j.Logger;
7373
import org.slf4j.LoggerFactory;
7474

@@ -1605,7 +1605,7 @@ private void revokeGrantRecord(
16051605
PolarisStorageConfigurationInfo storageConfigurationInfo =
16061606
BaseMetaStoreManager.extractStorageConfiguration(callCtx, reloadedEntity.getEntity());
16071607
try {
1608-
EnumMap<IcebergStorageAccessProperty, String> creds =
1608+
EnumMap<StorageAccessProperty, String> creds =
16091609
storageIntegration.getSubscopedCreds(
16101610
callCtx.getDiagServices(),
16111611
storageConfigurationInfo,

polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/entity/ScopedCredentialsResult.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
import jakarta.annotation.Nullable;
2525
import java.util.EnumMap;
2626
import java.util.Map;
27-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
27+
import org.apache.polaris.core.storage.StorageAccessProperty;
2828

2929
/** Result of a getSubscopedCredsForEntity() call */
3030
public class ScopedCredentialsResult extends BaseResult {
3131

3232
// null if not success. Else, set of name/value pairs for the credentials
33-
private final EnumMap<IcebergStorageAccessProperty, String> credentials;
33+
private final EnumMap<StorageAccessProperty, String> credentials;
3434

3535
/**
3636
* Constructor for an error
@@ -49,8 +49,7 @@ public ScopedCredentialsResult(
4949
*
5050
* @param credentials credentials
5151
*/
52-
public ScopedCredentialsResult(
53-
@Nonnull EnumMap<IcebergStorageAccessProperty, String> credentials) {
52+
public ScopedCredentialsResult(@Nonnull EnumMap<StorageAccessProperty, String> credentials) {
5453
super(ReturnStatus.SUCCESS);
5554
this.credentials = credentials;
5655
}
@@ -61,14 +60,13 @@ private ScopedCredentialsResult(
6160
@JsonProperty("extraInformation") String extraInformation,
6261
@JsonProperty("credentials") Map<String, String> credentials) {
6362
super(returnStatus, extraInformation);
64-
this.credentials = new EnumMap<>(IcebergStorageAccessProperty.class);
63+
this.credentials = new EnumMap<>(StorageAccessProperty.class);
6564
if (credentials != null) {
66-
credentials.forEach(
67-
(k, v) -> this.credentials.put(IcebergStorageAccessProperty.valueOf(k), v));
65+
credentials.forEach((k, v) -> this.credentials.put(StorageAccessProperty.valueOf(k), v));
6866
}
6967
}
7068

71-
public EnumMap<IcebergStorageAccessProperty, String> getCredentials() {
69+
public EnumMap<StorageAccessProperty, String> getCredentials() {
7270
return credentials;
7371
}
7472
}

polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/TransactionalMetaStoreManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
import org.apache.polaris.core.policy.PolicyEntity;
6868
import org.apache.polaris.core.policy.PolicyMappingUtil;
6969
import org.apache.polaris.core.policy.PolicyType;
70-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
7170
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
7271
import org.apache.polaris.core.storage.PolarisStorageIntegration;
72+
import org.apache.polaris.core.storage.StorageAccessProperty;
7373
import org.slf4j.Logger;
7474
import org.slf4j.LoggerFactory;
7575

@@ -2035,7 +2035,7 @@ private PolarisEntityResolver resolveSecurableToRoleGrant(
20352035
PolarisStorageConfigurationInfo storageConfigurationInfo =
20362036
BaseMetaStoreManager.extractStorageConfiguration(callCtx, reloadedEntity.getEntity());
20372037
try {
2038-
EnumMap<IcebergStorageAccessProperty, String> creds =
2038+
EnumMap<StorageAccessProperty, String> creds =
20392039
storageIntegration.getSubscopedCreds(
20402040
callCtx.getDiagServices(),
20412041
storageConfigurationInfo,

polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageIntegration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public String getStorageIdentifierOrId() {
5454
* @param allowedWriteLocations a set of allowed to write locations
5555
* @return An enum map including the scoped credentials
5656
*/
57-
public abstract EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
57+
public abstract EnumMap<StorageAccessProperty, String> getSubscopedCreds(
5858
@Nonnull PolarisDiagnostics diagnostics,
5959
@Nonnull T storageConfig,
6060
boolean allowListOperation,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* <p>Most of these properties are meant to configure Iceberg FileIO objects for accessing data in
2525
* storage.
2626
*/
27-
public enum IcebergStorageAccessProperty {
27+
public enum StorageAccessProperty {
2828
AWS_KEY_ID(String.class, "s3.access-key-id", "the aws access key id"),
2929
AWS_SECRET_KEY(String.class, "s3.secret-access-key", "the aws access key secret"),
3030
AWS_TOKEN(String.class, "s3.session-token", "the aws scoped access token"),
@@ -65,11 +65,11 @@ public enum IcebergStorageAccessProperty {
6565
- `s3.secret-access-key`: secret for credentials that provide access to data in S3
6666
- `s3.session-token
6767
*/
68-
IcebergStorageAccessProperty(Class valueType, String propertyName, String description) {
68+
StorageAccessProperty(Class valueType, String propertyName, String description) {
6969
this(valueType, propertyName, description, true);
7070
}
7171

72-
IcebergStorageAccessProperty(
72+
StorageAccessProperty(
7373
Class valueType, String propertyName, String description, boolean isCredential) {
7474
this.valueType = valueType;
7575
this.propertyName = propertyName;

polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsCredentialsStorageIntegration.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import java.util.Set;
3131
import java.util.stream.Stream;
3232
import org.apache.polaris.core.PolarisDiagnostics;
33-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
3433
import org.apache.polaris.core.storage.InMemoryStorageIntegration;
34+
import org.apache.polaris.core.storage.StorageAccessProperty;
3535
import org.apache.polaris.core.storage.StorageUtil;
3636
import software.amazon.awssdk.policybuilder.iam.IamConditionOperator;
3737
import software.amazon.awssdk.policybuilder.iam.IamEffect;
@@ -54,7 +54,7 @@ public AwsCredentialsStorageIntegration(StsClient stsClient) {
5454

5555
/** {@inheritDoc} */
5656
@Override
57-
public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
57+
public EnumMap<StorageAccessProperty, String> getSubscopedCreds(
5858
@Nonnull PolarisDiagnostics diagnostics,
5959
@Nonnull AwsStorageConfigurationInfo storageConfig,
6060
boolean allowListOperation,
@@ -75,30 +75,28 @@ public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
7575
.toJson())
7676
.durationSeconds(loadConfig(STORAGE_CREDENTIAL_DURATION_SECONDS))
7777
.build());
78-
EnumMap<IcebergStorageAccessProperty, String> credentialMap =
79-
new EnumMap<>(IcebergStorageAccessProperty.class);
78+
EnumMap<StorageAccessProperty, String> credentialMap =
79+
new EnumMap<>(StorageAccessProperty.class);
80+
credentialMap.put(StorageAccessProperty.AWS_KEY_ID, response.credentials().accessKeyId());
8081
credentialMap.put(
81-
IcebergStorageAccessProperty.AWS_KEY_ID, response.credentials().accessKeyId());
82-
credentialMap.put(
83-
IcebergStorageAccessProperty.AWS_SECRET_KEY, response.credentials().secretAccessKey());
84-
credentialMap.put(
85-
IcebergStorageAccessProperty.AWS_TOKEN, response.credentials().sessionToken());
82+
StorageAccessProperty.AWS_SECRET_KEY, response.credentials().secretAccessKey());
83+
credentialMap.put(StorageAccessProperty.AWS_TOKEN, response.credentials().sessionToken());
8684
Optional.ofNullable(response.credentials().expiration())
8785
.ifPresent(
8886
i -> {
8987
credentialMap.put(
90-
IcebergStorageAccessProperty.EXPIRATION_TIME, String.valueOf(i.toEpochMilli()));
88+
StorageAccessProperty.EXPIRATION_TIME, String.valueOf(i.toEpochMilli()));
9189
credentialMap.put(
92-
IcebergStorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS,
90+
StorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS,
9391
String.valueOf(i.toEpochMilli()));
9492
});
9593

9694
if (storageConfig.getRegion() != null) {
97-
credentialMap.put(IcebergStorageAccessProperty.CLIENT_REGION, storageConfig.getRegion());
95+
credentialMap.put(StorageAccessProperty.CLIENT_REGION, storageConfig.getRegion());
9896
}
9997

10098
if (storageConfig.getAwsPartition().equals("aws-us-gov")
101-
&& credentialMap.get(IcebergStorageAccessProperty.CLIENT_REGION) == null) {
99+
&& credentialMap.get(StorageAccessProperty.CLIENT_REGION) == null) {
102100
throw new IllegalArgumentException(
103101
String.format(
104102
"AWS region must be set when using partition %s", storageConfig.getAwsPartition()));

polaris-core/src/main/java/org/apache/polaris/core/storage/azure/AzureCredentialsStorageIntegration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
import java.util.Set;
4848
import org.apache.polaris.core.PolarisDiagnostics;
4949
import org.apache.polaris.core.config.FeatureConfiguration;
50-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
5150
import org.apache.polaris.core.storage.InMemoryStorageIntegration;
51+
import org.apache.polaris.core.storage.StorageAccessProperty;
5252
import org.slf4j.Logger;
5353
import org.slf4j.LoggerFactory;
5454
import reactor.core.publisher.Mono;
@@ -70,14 +70,14 @@ public AzureCredentialsStorageIntegration() {
7070
}
7171

7272
@Override
73-
public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
73+
public EnumMap<StorageAccessProperty, String> getSubscopedCreds(
7474
@Nonnull PolarisDiagnostics diagnostics,
7575
@Nonnull AzureStorageConfigurationInfo storageConfig,
7676
boolean allowListOperation,
7777
@Nonnull Set<String> allowedReadLocations,
7878
@Nonnull Set<String> allowedWriteLocations) {
79-
EnumMap<IcebergStorageAccessProperty, String> credentialMap =
80-
new EnumMap<>(IcebergStorageAccessProperty.class);
79+
EnumMap<StorageAccessProperty, String> credentialMap =
80+
new EnumMap<>(StorageAccessProperty.class);
8181
String loc =
8282
!allowedWriteLocations.isEmpty()
8383
? allowedWriteLocations.stream().findAny().orElse(null)
@@ -170,10 +170,10 @@ public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
170170
throw new RuntimeException(
171171
String.format("Endpoint %s not supported", location.getEndpoint()));
172172
}
173-
credentialMap.put(IcebergStorageAccessProperty.AZURE_SAS_TOKEN, sasToken);
174-
credentialMap.put(IcebergStorageAccessProperty.AZURE_ACCOUNT_HOST, storageDnsName);
173+
credentialMap.put(StorageAccessProperty.AZURE_SAS_TOKEN, sasToken);
174+
credentialMap.put(StorageAccessProperty.AZURE_ACCOUNT_HOST, storageDnsName);
175175
credentialMap.put(
176-
IcebergStorageAccessProperty.EXPIRATION_TIME,
176+
StorageAccessProperty.EXPIRATION_TIME,
177177
String.valueOf(sanitizedEndTime.toInstant().toEpochMilli()));
178178
return credentialMap;
179179
}

polaris-core/src/main/java/org/apache/polaris/core/storage/cache/StorageCredentialCacheEntry.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import java.util.function.BiConsumer;
2323
import org.apache.polaris.core.persistence.dao.entity.ScopedCredentialsResult;
2424
import org.apache.polaris.core.storage.AccessConfig;
25-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
2625
import org.apache.polaris.core.storage.ImmutableAccessConfig;
26+
import org.apache.polaris.core.storage.StorageAccessProperty;
2727
import org.apache.polaris.core.storage.azure.AzureLocation;
2828

2929
/** A storage credential cached entry. */
3030
public class StorageCredentialCacheEntry {
3131
/** The scoped creds map that is fetched from a creds vending service */
32-
public final EnumMap<IcebergStorageAccessProperty, String> credsMap;
32+
public final EnumMap<StorageAccessProperty, String> credsMap;
3333

3434
private final ScopedCredentialsResult scopedCredentialsResult;
3535

@@ -40,15 +40,14 @@ public StorageCredentialCacheEntry(ScopedCredentialsResult scopedCredentialsResu
4040

4141
/** Get the expiration time in millisecond for the cached entry */
4242
public long getExpirationTime() {
43-
if (credsMap.containsKey(IcebergStorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT)) {
44-
return Long.parseLong(credsMap.get(IcebergStorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT));
43+
if (credsMap.containsKey(StorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT)) {
44+
return Long.parseLong(credsMap.get(StorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT));
4545
}
46-
if (credsMap.containsKey(IcebergStorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS)) {
47-
return Long.parseLong(
48-
credsMap.get(IcebergStorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS));
46+
if (credsMap.containsKey(StorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS)) {
47+
return Long.parseLong(credsMap.get(StorageAccessProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS));
4948
}
50-
if (credsMap.containsKey(IcebergStorageAccessProperty.EXPIRATION_TIME)) {
51-
return Long.parseLong(credsMap.get(IcebergStorageAccessProperty.EXPIRATION_TIME));
49+
if (credsMap.containsKey(StorageAccessProperty.EXPIRATION_TIME)) {
50+
return Long.parseLong(credsMap.get(StorageAccessProperty.EXPIRATION_TIME));
5251
}
5352
return Long.MAX_VALUE;
5453
}
@@ -58,11 +57,9 @@ public long getExpirationTime() {
5857
* account endpoint
5958
*/
6059
private void handleAzureCredential(
61-
BiConsumer<String, String> results,
62-
IcebergStorageAccessProperty credentialProperty,
63-
String value) {
64-
if (credentialProperty.equals(IcebergStorageAccessProperty.AZURE_SAS_TOKEN)) {
65-
String host = credsMap.get(IcebergStorageAccessProperty.AZURE_ACCOUNT_HOST);
60+
BiConsumer<String, String> results, StorageAccessProperty credentialProperty, String value) {
61+
if (credentialProperty.equals(StorageAccessProperty.AZURE_SAS_TOKEN)) {
62+
String host = credsMap.get(StorageAccessProperty.AZURE_ACCOUNT_HOST);
6663
results.accept(credentialProperty.getPropertyName() + host, value);
6764

6865
// Iceberg 1.7.x may expect the credential key to _not_ be suffixed with endpoint
@@ -99,9 +96,9 @@ AccessConfig toAccessConfig() {
9996
return;
10097
}
10198

102-
if (key.equals(IcebergStorageAccessProperty.AZURE_SAS_TOKEN)) {
99+
if (key.equals(StorageAccessProperty.AZURE_SAS_TOKEN)) {
103100
handleAzureCredential(config::putCredential, key, value);
104-
} else if (!key.equals(IcebergStorageAccessProperty.AZURE_ACCOUNT_HOST)) {
101+
} else if (!key.equals(StorageAccessProperty.AZURE_ACCOUNT_HOST)) {
105102
config.putCredential(key.getPropertyName(), value);
106103
}
107104
});

polaris-core/src/main/java/org/apache/polaris/core/storage/gcp/GcpCredentialsStorageIntegration.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
import java.util.Set;
4040
import java.util.stream.Stream;
4141
import org.apache.polaris.core.PolarisDiagnostics;
42-
import org.apache.polaris.core.storage.IcebergStorageAccessProperty;
4342
import org.apache.polaris.core.storage.InMemoryStorageIntegration;
4443
import org.apache.polaris.core.storage.PolarisStorageIntegration;
44+
import org.apache.polaris.core.storage.StorageAccessProperty;
4545
import org.apache.polaris.core.storage.StorageUtil;
4646
import org.slf4j.Logger;
4747
import org.slf4j.LoggerFactory;
@@ -69,7 +69,7 @@ public GcpCredentialsStorageIntegration(
6969
}
7070

7171
@Override
72-
public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
72+
public EnumMap<StorageAccessProperty, String> getSubscopedCreds(
7373
@Nonnull PolarisDiagnostics diagnostics,
7474
@Nonnull GcpStorageConfigurationInfo storageConfig,
7575
boolean allowListOperation,
@@ -106,11 +106,10 @@ public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
106106

107107
// If expires_in missing, use source credential's expire time, which require another api call to
108108
// get.
109-
EnumMap<IcebergStorageAccessProperty, String> propertyMap =
110-
new EnumMap<>(IcebergStorageAccessProperty.class);
111-
propertyMap.put(IcebergStorageAccessProperty.GCS_ACCESS_TOKEN, token.getTokenValue());
109+
EnumMap<StorageAccessProperty, String> propertyMap = new EnumMap<>(StorageAccessProperty.class);
110+
propertyMap.put(StorageAccessProperty.GCS_ACCESS_TOKEN, token.getTokenValue());
112111
propertyMap.put(
113-
IcebergStorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT,
112+
StorageAccessProperty.GCS_ACCESS_TOKEN_EXPIRES_AT,
114113
String.valueOf(token.getExpirationTime().getTime()));
115114
return propertyMap;
116115
}

polaris-core/src/test/java/org/apache/polaris/core/storage/InMemoryStorageIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public MockInMemoryStorageIntegration() {
207207
}
208208

209209
@Override
210-
public EnumMap<IcebergStorageAccessProperty, String> getSubscopedCreds(
210+
public EnumMap<StorageAccessProperty, String> getSubscopedCreds(
211211
@Nonnull PolarisDiagnostics diagnostics,
212212
@Nonnull PolarisStorageConfigurationInfo storageConfig,
213213
boolean allowListOperation,

0 commit comments

Comments
 (0)