atharvalade commented on code in PR #2889:
URL: https://github.com/apache/iggy/pull/2889#discussion_r2900553732


##########
core/connectors/sinks/delta_sink/src/storage.rs:
##########
@@ -0,0 +1,277 @@
+/* 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.
+ */
+
+use crate::DeltaSinkConfig;
+use iggy_connector_sdk::Error;
+use std::collections::HashMap;
+
+pub(crate) fn build_storage_options(
+    config: &DeltaSinkConfig,
+) -> Result<HashMap<String, String>, Error> {
+    let mut opts = HashMap::new();
+
+    match config.storage_backend_type.as_deref() {
+        Some("s3") => {
+            let access_key = config
+                .aws_s3_access_key
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let secret_key = config
+                .aws_s3_secret_key
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let region = 
config.aws_s3_region.as_ref().ok_or(Error::InvalidConfig)?;
+            let endpoint_url = config
+                .aws_s3_endpoint_url
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let allow_http = 
config.aws_s3_allow_http.ok_or(Error::InvalidConfig)?;

Review Comment:
   `aws_s3_endpoint_url` and `aws_s3_allow_http` are hard-required via 
`.ok_or(Error::InvalidConfig)?`, but both are optional in 
`delta-rs/object_store`. `AWS_ENDPOINT_URL` defaults to the standard AWS S3 
regional endpoint when omitted, and `AWS_ALLOW_HTTP` defaults to false. This 
means users connecting to real AWS S3 (not MinIO/LocalStack) are forced to 
provide values that shouldn't be necessary. These two fields should be added to 
the options map only when present, not treated as required.



##########
core/connectors/sinks/delta_sink/src/storage.rs:
##########
@@ -0,0 +1,277 @@
+/* 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.
+ */
+
+use crate::DeltaSinkConfig;
+use iggy_connector_sdk::Error;
+use std::collections::HashMap;
+
+pub(crate) fn build_storage_options(
+    config: &DeltaSinkConfig,
+) -> Result<HashMap<String, String>, Error> {
+    let mut opts = HashMap::new();
+
+    match config.storage_backend_type.as_deref() {
+        Some("s3") => {
+            let access_key = config
+                .aws_s3_access_key
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let secret_key = config
+                .aws_s3_secret_key
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let region = 
config.aws_s3_region.as_ref().ok_or(Error::InvalidConfig)?;
+            let endpoint_url = config
+                .aws_s3_endpoint_url
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let allow_http = 
config.aws_s3_allow_http.ok_or(Error::InvalidConfig)?;
+
+            opts.insert("AWS_ACCESS_KEY_ID".into(), access_key.clone());
+            opts.insert("AWS_SECRET_ACCESS_KEY".into(), secret_key.clone());
+            opts.insert("AWS_REGION".into(), region.clone());
+            opts.insert("AWS_ENDPOINT_URL".into(), endpoint_url.clone());
+            opts.insert("AWS_ALLOW_HTTP".into(), allow_http.to_string());
+            opts.insert("AWS_S3_ALLOW_HTTP".into(), allow_http.to_string());
+        }
+        Some("azure") => {
+            let account_name = config
+                .azure_storage_account_name
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let account_key = config
+                .azure_storage_account_key
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;
+            let sas_token = config
+                .azure_storage_sas_token
+                .as_ref()
+                .ok_or(Error::InvalidConfig)?;

Review Comment:
   Both `azure_storage_account_key` and `azure_storage_sas_token` are required 
simultaneously via `.ok_or(Error::InvalidConfig)?`. In Azure, these are 
alternative authentication methods. you use either an account key or a SAS 
token, not both. This blocks users who only have a SAS token (common in 
restricted-access scenarios). The code should require `account_name` and at 
least one of `account_key` or `sas_token`, and only insert whichever credential 
is provided.



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