dimas-b commented on code in PR #3699:
URL: https://github.com/apache/polaris/pull/3699#discussion_r3337661057


##########
polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsStorageCredentialCacheKey.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.storage.aws;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.storage.StorageAccessConfig;
+import org.apache.polaris.core.storage.cache.StorageCredentialCacheKey;
+import org.apache.polaris.immutables.PolarisImmutable;
+import org.immutables.value.Value;
+import org.jspecify.annotations.Nullable;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.services.sts.model.Tag;
+
+/**
+ * Cache key for vended AWS credentials. Data fields drive equality (cache 
identity); auxiliary
+ * fields carry the app-scoped deps that {@link #load()} needs to mint a fresh 
credential on miss.
+ */
+@PolarisImmutable
+public interface AwsStorageCredentialCacheKey extends 
StorageCredentialCacheKey {
+
+  // ---- data fields: part of equals/hashCode ----
+
+  @Value.Parameter(order = 1)
+  String realmId();
+
+  @Value.Parameter(order = 2)
+  @Nullable String storageConfigSerializedStr();
+
+  @Value.Parameter(order = 3)
+  Set<String> allowedReadLocations();
+
+  @Value.Parameter(order = 4)
+  Set<String> allowedListLocations();
+
+  @Value.Parameter(order = 5)
+  Set<String> allowedWriteLocations();
+
+  @Value.Parameter(order = 6)
+  Optional<String> refreshCredentialsEndpoint();
+
+  @Value.Parameter(order = 7)
+  String roleSessionName();
+
+  @Value.Parameter(order = 8)
+  List<Tag> sessionTags();
+
+  // ---- aux: app-scoped invariants, excluded from equals/hashCode ----
+
+  @Value.Parameter(order = 9)
+  @Value.Auxiliary
+  StsClientProvider stsClientProvider();

Review Comment:
   I'm still a bit hesitant about keeping this state (effectively 
application-scoped) in the cache key, but current logic looks correct 
nonetheless, so I'm fine with this... Maybe we can improve more later :)



##########
polaris-core/src/main/java/org/apache/polaris/core/storage/aws/AwsStorageCredentialCacheKey.java:
##########
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.core.storage.aws;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.storage.StorageAccessConfig;
+import org.apache.polaris.core.storage.cache.StorageCredentialCacheKey;
+import org.apache.polaris.immutables.PolarisImmutable;
+import org.immutables.value.Value;
+import org.jspecify.annotations.Nullable;
+import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
+import software.amazon.awssdk.services.sts.model.Tag;
+
+/**
+ * Cache key for vended AWS credentials. Data fields drive equality (cache 
identity); auxiliary
+ * fields carry the app-scoped deps that {@link #load()} needs to mint a fresh 
credential on miss.
+ */
+@PolarisImmutable
+public interface AwsStorageCredentialCacheKey extends 
StorageCredentialCacheKey {
+
+  // ---- data fields: part of equals/hashCode ----
+
+  @Value.Parameter(order = 1)
+  String realmId();
+
+  @Value.Parameter(order = 2)
+  @Nullable String storageConfigSerializedStr();
+
+  @Value.Parameter(order = 3)
+  Set<String> allowedReadLocations();
+
+  @Value.Parameter(order = 4)
+  Set<String> allowedListLocations();
+
+  @Value.Parameter(order = 5)
+  Set<String> allowedWriteLocations();
+
+  @Value.Parameter(order = 6)
+  Optional<String> refreshCredentialsEndpoint();
+
+  @Value.Parameter(order = 7)
+  String roleSessionName();
+
+  @Value.Parameter(order = 8)
+  List<Tag> sessionTags();
+
+  // ---- aux: app-scoped invariants, excluded from equals/hashCode ----
+
+  @Value.Parameter(order = 9)
+  @Value.Auxiliary
+  StsClientProvider stsClientProvider();
+
+  @Value.Parameter(order = 10)
+  @Value.Auxiliary
+  Function<AwsStorageConfigurationInfo, Optional<AwsCredentialsProvider>> 
credentialsResolver();
+
+  @Value.Parameter(order = 11)
+  @Value.Auxiliary
+  AwsStorageConfigurationInfo storageConfig();

Review Comment:
   This config is used inside the `.compute()` method... Why is it `Auxiliary`? 
If `storageConfig` is different, the value should be re-computed, right? 🤔 
   
   Shouldn't we break it down into individual elements and use only the latter 
inside `compute()`?



-- 
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]

Reply via email to