Skip to content

Conversation

flarco
Copy link

@flarco flarco commented Jun 11, 2025

Hello, these changes allowed to use iceberg-go with the Cloudflare R2 Data Catalog and AWS S3 Tables REST

Let me know if any formatting or changes/tests are needed.

io/s3.go Outdated
Comment on lines 281 to 299
host == "s3.amazonaws.com" ||
// Regional S3 endpoints
(len(host) > 12 && host[len(host)-12:] == ".amazonaws.com" && (host[:3] == "s3." || host[len(host)-17:len(host)-12] == ".s3")) ||
// Virtual hosted-style bucket access
(len(host) > 17 && host[len(host)-17:] == ".s3.amazonaws.com") ||
// Path-style access to S3
(len(host) > 3 && host[:3] == "s3.") ||
// Cloudflare R2 endpoints
(len(host) > 20 && host[len(host)-20:] == ".r2.cloudflarestorage.com") ||
// MinIO or other custom S3-compatible endpoints (be more conservative)
(len(host) > 0 && (host == "localhost:9000" || host == "127.0.0.1:9000" ||
// Only sign if it looks like an S3 request pattern (has bucket-like structure)
// and is NOT a catalog service (which typically has /catalog/ in the path)
(req.URL.Path != "" && !strings.Contains(req.URL.Path, "/catalog/") &&
!strings.Contains(host, "catalog") &&
// Exclude common non-S3 service patterns
!strings.Contains(host, "glue.") &&
!strings.Contains(host, "api.") &&
!strings.Contains(host, "catalog.")))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I would put this under a separate helper function. wdyt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it could be put in the utils folder? Although I don't think this logic will be used elsewhere, so not sure that there is much benefit breaking the function into pieces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we put it in io/utils.go. Wdyt @zeroshade ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utils folder are generally bad practice, i would even keep this function in this file, or as @dttung2905 proposed in io/utils.go file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to keep it in this file since there isn't any reusability. But I'm fine moving it as well. Who makes the final call ? 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flarco it's up to you, same file - it's good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants