Skip to content

Commit 00747e5

Browse files
feat: add configurable secure option for S3 storage
Allows disabling TLS for S3-compatible endpoints (e.g. local MinIO). Defaults to true when not specified.
1 parent 29443ab commit 00747e5

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

internal/config/storage/s3.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type S3Storage struct {
99
Region *string `hcl:"region"`
1010

1111
Prefix *string `hcl:"prefix"`
12+
Secure *bool `hcl:"secure"`
1213

1314
// Retention settings
1415
RetentionPeriod *string `hcl:"retention_period"`
@@ -22,3 +23,11 @@ func (s *S3Storage) GetRegion() string {
2223

2324
return *s.Region
2425
}
26+
27+
func (s *S3Storage) IsSecure() bool {
28+
if s.Secure == nil {
29+
return true
30+
}
31+
32+
return *s.Secure
33+
}

internal/storage/s3/upload.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func Upload(ctx context.Context, reader io.Reader) error {
2626
client, err := minio.New(config.Loaded.Storage.S3.Endpoint, &minio.Options{
2727
Creds: credentials.NewStaticV4(config.Loaded.Storage.S3.AccessKey, config.Loaded.Storage.S3.SecretKey, ""),
2828
Region: config.Loaded.Storage.S3.GetRegion(),
29-
Secure: true,
29+
Secure: config.Loaded.Storage.S3.IsSecure(),
3030
})
3131

3232
if err != nil {
@@ -170,7 +170,7 @@ func CleanupRetention(ctx context.Context) error {
170170
client, err := minio.New(config.Loaded.Storage.S3.Endpoint, &minio.Options{
171171
Creds: credentials.NewStaticV4(config.Loaded.Storage.S3.AccessKey, config.Loaded.Storage.S3.SecretKey, ""),
172172
Region: config.Loaded.Storage.S3.GetRegion(),
173-
Secure: true,
173+
Secure: config.Loaded.Storage.S3.IsSecure(),
174174
})
175175
if err != nil {
176176
return fmt.Errorf("failed to create S3 client: %w", err)
@@ -249,7 +249,7 @@ func CreateClient() (*minio.Client, error) {
249249
client, err := minio.New(config.Loaded.Storage.S3.Endpoint, &minio.Options{
250250
Creds: credentials.NewStaticV4(config.Loaded.Storage.S3.AccessKey, config.Loaded.Storage.S3.SecretKey, ""),
251251
Region: config.Loaded.Storage.S3.GetRegion(),
252-
Secure: true,
252+
Secure: config.Loaded.Storage.S3.IsSecure(),
253253
})
254254

255255
if err != nil {

0 commit comments

Comments
 (0)