From 5f6d9cb3359b001c74200650e8240b410c1e08f0 Mon Sep 17 00:00:00 2001 From: Vadim Voitenko Date: Thu, 4 Apr 2024 13:41:00 +0200 Subject: [PATCH 1/2] Fixed broken S3 storage after structure refactoring * Fixed S3 storage * Deleted Validate method * Fixed playground config.yml --- internal/storages/builder/builder.go | 3 --- internal/storages/s3/config.go | 11 ----------- playground/config.yml | 1 + 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/internal/storages/builder/builder.go b/internal/storages/builder/builder.go index c61b0e78..9c57178d 100644 --- a/internal/storages/builder/builder.go +++ b/internal/storages/builder/builder.go @@ -40,9 +40,6 @@ func GetStorage(ctx context.Context, stCfg *domains.StorageConfig, logCgf *domai } return directory.NewStorage(stCfg.Directory) case S3StorageType: - if err := stCfg.S3.Validate(); err != nil { - return nil, fmt.Errorf("s3 storage config validation failed: %w", err) - } return s3.NewStorage(ctx, stCfg.S3, logCgf.Level) } return nil, fmt.Errorf("unknown storage type: %s", stCfg.Type) diff --git a/internal/storages/s3/config.go b/internal/storages/s3/config.go index 84fa1be8..975dcd0a 100644 --- a/internal/storages/s3/config.go +++ b/internal/storages/s3/config.go @@ -14,10 +14,6 @@ package s3 -import ( - "errors" -) - const ( defaultMaxRetries = 3 defaultMaxPartSize = 50 * 1024 * 1024 @@ -53,10 +49,3 @@ func NewConfig() *Config { MaxPartSize: defaultMaxPartSize, } } - -func (c *Config) Validate() error { - if c.Region != "" { - return errors.New("region cannot be empty") - } - return nil -} diff --git a/playground/config.yml b/playground/config.yml index e92dbbc8..9387b026 100644 --- a/playground/config.yml +++ b/playground/config.yml @@ -3,6 +3,7 @@ common: tmp_dir: "/tmp" storage: + type: "s3" s3: endpoint: "http://playground-storage:9000" bucket: "adventureworks" From 91a2a21372c8153fcc157e6932712b82a0337803 Mon Sep 17 00:00:00 2001 From: Vadim Voitenko Date: Thu, 4 Apr 2024 13:42:59 +0200 Subject: [PATCH 2/2] Added constants for s3 storage --- internal/storages/s3/config.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/storages/s3/config.go b/internal/storages/s3/config.go index 975dcd0a..0c5ad765 100644 --- a/internal/storages/s3/config.go +++ b/internal/storages/s3/config.go @@ -15,8 +15,10 @@ package s3 const ( - defaultMaxRetries = 3 - defaultMaxPartSize = 50 * 1024 * 1024 + defaultMaxRetries = 3 + defaultMaxPartSize = 50 * 1024 * 1024 + defaultStorageClass = "STANDARD" + defaultForcePath = true ) type Config struct { @@ -43,8 +45,8 @@ type Config struct { func NewConfig() *Config { return &Config{ - StorageClass: "STANDARD", - ForcePathStyle: true, + StorageClass: defaultStorageClass, + ForcePathStyle: defaultForcePath, MaxRetries: defaultMaxRetries, MaxPartSize: defaultMaxPartSize, }