Skip to content

feat: custom s3 url #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: custom s3 url #14

wants to merge 1 commit into from

Conversation

hown3d
Copy link

@hown3d hown3d commented Jun 16, 2025

Allows to use custom endpoints that implement s3 API.

Signed-off-by: Lukas Hoehl <[email protected]>
Copy link
Member

@creachadair creachadair left a comment

Choose a reason for hiding this comment

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

This change seems fine, but we should also update the documentation in help.go, and I have a few other small comments inline.

Can you please also update the commit title and description to provide more context for what this is doing? We also don't use the conventional-commits type tags like "feat" for PR titles.

A suggestion for example:

cmd/go-cache-plugin: add support for a custom S3 endpoint URL

This allows use of other S3-compatible implementations for cache storage.

or words to that effect.

@@ -26,6 +26,7 @@ var flags struct {
CacheDir string `flag:"cache-dir,default=$GOCACHE_DIR,Local cache directory (required)"`
S3Bucket string `flag:"bucket,default=$GOCACHE_S3_BUCKET,S3 bucket name (required)"`
S3Region string `flag:"region,default=$GOCACHE_S3_REGION,S3 region"`
S3URL string `flag:"s3-url,default=$GOCACHE_S3_URL,S3 URL"`
Copy link
Member

Choose a reason for hiding this comment

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

I think this flag needs a more descriptive name. Perhaps:

Suggested change
S3URL string `flag:"s3-url,default=$GOCACHE_S3_URL,S3 URL"`
S3Endpoint string `flag:"s3-endpoint-url,default=$GOCACHE_S3_ENDPOINT_URL,S3 custom endpoint URL (if unset, use AWS default)"`

In particular: Make the name reflect that this is the endpoint URL, and note the meaning of the default.

@@ -62,10 +62,19 @@ func initCacheServer(env *command.Env) (*gocache.Server, *s3util.Client, error)

vprintf("local cache directory: %s", flags.CacheDir)
vprintf("S3 cache bucket %q (%s)", flags.S3Bucket, region)
client := &s3util.Client{
Client: s3.NewFromConfig(cfg, func(o *s3.Options) {
s3opts := []func(*s3.Options){
Copy link
Member

Choose a reason for hiding this comment

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

Naming nit: Mixed case, please. I would just call this opts since there are no other options in scope here.

},
}
if flags.S3URL != "" {
vprintf("S3 URL: %s", flags.S3URL)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
vprintf("S3 URL: %s", flags.S3URL)
vprintf("S3 endpoint URL: %s", flags.S3Endpoint)

if flags.S3URL != "" {
vprintf("S3 URL: %s", flags.S3URL)
s3opts = append(s3opts, func(o *s3.Options) {
o.BaseEndpoint = &flags.S3URL
Copy link
Member

Choose a reason for hiding this comment

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

I suggest making this

Suggested change
o.BaseEndpoint = &flags.S3URL
o.BaseEndpoint = aws.String(flags.S3URL)

The meaning is the same, but makes the intent clearer.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, actually maybe a better way to do this is to add config.WithBaseEndpoint to the LoadDefaultConfig call, instead of here?

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.

2 participants