Skip to content

Commit f38d547

Browse files
renovate[bot]fclairambclaude
authored
fix(deps): update module github.com/fclairamb/afero-s3 to v0.4.0 (#1579)
* fix(deps): update module github.com/fclairamb/afero-s3 to v0.4.0 * fix(s3): update to AWS SDK v2 for afero-s3 v0.4.0 compatibility The afero-s3 v0.4.0 library migrated from AWS SDK v1 to v2, replacing `NewFs(bucket, session)` with `NewFsFromClient(bucket, client)` and `NewFsFromConfig(bucket, config)`. This commit updates the S3 filesystem implementation to: - Use AWS SDK v2 config and credentials packages - Create an S3 client with proper options for endpoint, path style, etc. - Use NewFsFromClient to initialize the afero-s3 filesystem Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Florent Clairambault <florent.clairambault@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 10b59b1 commit f38d547

File tree

3 files changed

+111
-91
lines changed

3 files changed

+111
-91
lines changed

fs/s3/s3.go

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
package s3
33

44
import (
5-
"github.com/aws/aws-sdk-go/aws"
6-
"github.com/aws/aws-sdk-go/aws/credentials"
7-
"github.com/aws/aws-sdk-go/aws/session"
8-
s3 "github.com/fclairamb/afero-s3"
5+
"context"
6+
7+
"github.com/aws/aws-sdk-go-v2/aws"
8+
"github.com/aws/aws-sdk-go-v2/config"
9+
"github.com/aws/aws-sdk-go-v2/credentials"
10+
"github.com/aws/aws-sdk-go-v2/service/s3"
11+
aferos3 "github.com/fclairamb/afero-s3"
912
"github.com/spf13/afero"
1013

1114
"github.com/fclairamb/ftpserver/config/confpar"
@@ -18,30 +21,53 @@ func LoadFs(access *confpar.Access) (afero.Fs, error) {
1821
bucket := access.Params["bucket"]
1922
keyID := access.Params["access_key_id"]
2023
secretAccessKey := access.Params["secret_access_key"]
24+
disableSSL := access.Params["disable_ssl"] == "true"
25+
pathStyle := access.Params["path_style"] == "true"
26+
27+
// Build config options for AWS SDK v2
28+
var configOpts []func(*config.LoadOptions) error
2129

22-
conf := aws.Config{
23-
Region: aws.String(region),
24-
DisableSSL: aws.Bool(access.Params["disable_ssl"] == "true"),
25-
S3ForcePathStyle: aws.Bool(access.Params["path_style"] == "true"),
30+
if region != "" {
31+
configOpts = append(configOpts, config.WithRegion(region))
2632
}
2733

2834
if keyID != "" && secretAccessKey != "" {
29-
conf.Credentials = credentials.NewStaticCredentials(keyID, secretAccessKey, "")
35+
configOpts = append(configOpts, config.WithCredentialsProvider(
36+
credentials.NewStaticCredentialsProvider(keyID, secretAccessKey, ""),
37+
))
3038
}
3139

32-
if endpoint != "" {
33-
conf.Endpoint = aws.String(endpoint)
40+
cfg, err := config.LoadDefaultConfig(context.Background(), configOpts...)
41+
if err != nil {
42+
return nil, err
3443
}
3544

36-
sess, errSession := session.NewSession(&conf)
45+
// Build S3 client options
46+
var s3Opts []func(*s3.Options)
47+
48+
if endpoint != "" {
49+
endpointURL := endpoint
50+
if disableSSL {
51+
// Ensure HTTP scheme if SSL is disabled
52+
if len(endpointURL) > 0 && endpointURL[0] != 'h' {
53+
endpointURL = "http://" + endpointURL
54+
}
55+
}
56+
s3Opts = append(s3Opts, func(o *s3.Options) {
57+
o.BaseEndpoint = aws.String(endpointURL)
58+
})
59+
}
3760

38-
if errSession != nil {
39-
return nil, errSession
61+
if pathStyle {
62+
s3Opts = append(s3Opts, func(o *s3.Options) {
63+
o.UsePathStyle = true
64+
})
4065
}
4166

42-
s3Fs := s3.NewFs(bucket, sess)
67+
// Create S3 client with options
68+
client := s3.NewFromConfig(cfg, s3Opts...)
4369

44-
// s3Fs = stripprefix.NewStripPrefixFs(s3Fs, 1)
70+
s3Fs := aferos3.NewFsFromClient(bucket, client)
4571

4672
return s3Fs, nil
4773
}

go.mod

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ toolchain go1.25.6
77
require (
88
cloud.google.com/go/storage v1.59.1
99
github.com/Nerzal/gocloak/v13 v13.9.0
10-
github.com/aws/aws-sdk-go v1.55.8
10+
github.com/aws/aws-sdk-go-v2 v1.41.1
11+
github.com/aws/aws-sdk-go-v2/config v1.32.7
12+
github.com/aws/aws-sdk-go-v2/credentials v1.19.7
13+
github.com/aws/aws-sdk-go-v2/service/s3 v1.95.1
1114
github.com/fclairamb/afero-dropbox v0.1.0
1215
github.com/fclairamb/afero-gdrive v0.3.0
13-
github.com/fclairamb/afero-s3 v0.3.1
16+
github.com/fclairamb/afero-s3 v0.4.0
1417
github.com/fclairamb/afero-snd v0.2.0
1518
github.com/fclairamb/ftpserverlib v0.29.0
1619
github.com/go-crypt/crypt v0.4.7
@@ -75,11 +78,26 @@ require (
7578
)
7679

7780
require (
81+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.4 // indirect
82+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.17 // indirect
83+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.19 // indirect
84+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
85+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.17 // indirect
86+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
87+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.17 // indirect
88+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.4 // indirect
89+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.8 // indirect
90+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.17 // indirect
91+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.17 // indirect
92+
github.com/aws/aws-sdk-go-v2/service/signin v1.0.5 // indirect
93+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.9 // indirect
94+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.13 // indirect
95+
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirect
96+
github.com/aws/smithy-go v1.24.0 // indirect
7897
github.com/dropbox/dropbox-sdk-go-unofficial v5.6.0+incompatible // indirect
7998
github.com/fclairamb/go-log v0.6.0 // indirect
8099
github.com/googleapis/enterprise-certificate-proxy v0.3.11 // indirect
81100
github.com/googleapis/gax-go/v2 v2.16.0 // indirect
82-
github.com/jmespath/go-jmespath v0.4.0 // indirect
83101
github.com/kr/fs v0.1.0 // indirect
84102
golang.org/x/net v0.49.0 // indirect
85103
golang.org/x/sys v0.40.0 // indirect

0 commit comments

Comments
 (0)