Skip to content
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

Fixed s3 region env variable providing #37

Merged
merged 7 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ two storage options are supported: `directory` and `s3`.
* `prefix` — a prefix for objects in the bucket, specified in path format
* `region` — the S3 service region
* `storage_class` — the storage class for performing object requests
* `disable_ssl` — disable SSL for interactions (default is `false`)
* `no_verify_ssl` — disable SSL certificate verification
* `access_key_id` — access key for authentication
* `secret_access_key` — secret access key for authentication
* `session_token` — session token for authentication
Expand Down
1 change: 1 addition & 0 deletions internal/storages/s3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Config struct {
UseListObjectsV1 bool `mapstructure:"use_list_objects_v1,omitempty"`
ForcePathStyle bool `mapstructure:"force_path_style,omitempty"`
UseAccelerate bool `mapstructure:"use_accelerate,omitempty"`
NoVerifySsl bool `mapstructure:"no_verify_ssl,omitempty"`
}

func NewConfig() *Config {
Expand Down
19 changes: 18 additions & 1 deletion internal/storages/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ package s3

import (
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"net/http"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -122,10 +124,20 @@ func NewStorage(ctx context.Context, cfg *Config, logLevel string) (*Storage, er
awsCfg.WithLogger(LogWrapper{logger: &log.Logger})
awsCfg.WithLogLevel(lv)

if cfg.NoVerifySsl {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
awsCfg.WithHTTPClient(&http.Client{Transport: tr})
}

if cfg.Endpoint != "" {
awsCfg.WithEndpoint(cfg.Endpoint)
}
awsCfg.WithRegion(cfg.Region)

if cfg.Region != "" {
awsCfg.WithRegion(cfg.Region)
}

if cfg.CertFile != "" {
file, err := os.Open(cfg.CertFile)
Expand All @@ -147,6 +159,11 @@ func NewStorage(ctx context.Context, cfg *Config, logLevel string) (*Storage, er
},
)

log.Debug().
Str("region", *service.Config.Region).
Str("bucket", cfg.Bucket).
Msg("s3 storage bucket")

return &Storage{
prefix: fixPrefix(path.Join(cfg.Bucket, cfg.Prefix)),
session: ses,
Expand Down