Skip to content

cmd/go-cache-plugin: custom s3 endpoint 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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

hown3d
Copy link
Contributor

@hown3d hown3d commented Jun 16, 2025

Allows to use custom endpoints that implement s3 API.

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?

@hown3d hown3d changed the title feat: custom s3 url custom s3 url Jun 17, 2025
@hown3d hown3d changed the title custom s3 url cmd/go-cache-plugin: custom s3 endpoint url Jun 17, 2025
This allows use of other S3-compatible implementations for cache storage.

Signed-off-by: Lukas Hoehl <[email protected]>
@creachadair creachadair merged commit d651c79 into tailscale:main Jun 18, 2025
1 check passed
@creachadair
Copy link
Member

This is now tagged at and after v0.1.1.

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