Skip to content

Commit

Permalink
Merge pull request #52 from GreenmaskIO/fix_broken_s3_st
Browse files Browse the repository at this point in the history
Fixed broken S3 storage after structure refactoring
  • Loading branch information
wwoytenko authored Apr 4, 2024
2 parents 0970d8e + 91a2a21 commit ce23c93
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
3 changes: 0 additions & 3 deletions internal/storages/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 6 additions & 15 deletions internal/storages/s3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@

package s3

import (
"errors"
)

const (
defaultMaxRetries = 3
defaultMaxPartSize = 50 * 1024 * 1024
defaultMaxRetries = 3
defaultMaxPartSize = 50 * 1024 * 1024
defaultStorageClass = "STANDARD"
defaultForcePath = true
)

type Config struct {
Expand All @@ -47,16 +45,9 @@ type Config struct {

func NewConfig() *Config {
return &Config{
StorageClass: "STANDARD",
ForcePathStyle: true,
StorageClass: defaultStorageClass,
ForcePathStyle: defaultForcePath,
MaxRetries: defaultMaxRetries,
MaxPartSize: defaultMaxPartSize,
}
}

func (c *Config) Validate() error {
if c.Region != "" {
return errors.New("region cannot be empty")
}
return nil
}
1 change: 1 addition & 0 deletions playground/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ common:
tmp_dir: "/tmp"

storage:
type: "s3"
s3:
endpoint: "http://playground-storage:9000"
bucket: "adventureworks"
Expand Down

0 comments on commit ce23c93

Please sign in to comment.