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

remove pointer from storage config definition #55

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 2 additions & 2 deletions internal/domains/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ type Common struct {

type StorageConfig struct {
Type string `mapstructure:"type" yaml:"type" json:"type,omitempty"`
S3 *s3.Config `mapstructure:"s3" json:"s3,omitempty" yaml:"s3"`
Directory *directory.Config `mapstructure:"directory" json:"directory,omitempty" yaml:"directory"`
S3 s3.Config `mapstructure:"s3" json:"s3,omitempty" yaml:"s3"`
Directory directory.Config `mapstructure:"directory" json:"directory,omitempty" yaml:"directory"`
}

type LogConfig struct {
Expand Down
4 changes: 2 additions & 2 deletions internal/storages/directory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ type Config struct {
Path string `mapstructure:"path"`
}

func NewConfig() *Config {
return &Config{}
func NewConfig() Config {
return Config{}
}

func (d *Config) Validate() error {
Expand Down
2 changes: 1 addition & 1 deletion internal/storages/directory/directiry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (suite *DirectorySuite) SetupSuite() {
suite.tmpDir, err = os.MkdirTemp(tempDir, "directory_storage_unit_test_")
suite.Require().NoError(err)

suite.st, err = NewStorage(&Config{Path: suite.tmpDir})
suite.st, err = NewStorage(Config{Path: suite.tmpDir})
suite.Require().NoError(err)
}

Expand Down
2 changes: 1 addition & 1 deletion internal/storages/directory/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Storage struct {
mx sync.Mutex
}

func NewStorage(cfg *Config) (*Storage, error) {
func NewStorage(cfg Config) (*Storage, error) {
// TODO: We would replace hardcoded file mask to Umask for unix system
fileInfo, err := os.Stat(cfg.Path)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/storages/s3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ type Config struct {
NoVerifySsl bool `mapstructure:"no_verify_ssl,omitempty"`
}

func NewConfig() *Config {
return &Config{
func NewConfig() Config {
return Config{
StorageClass: defaultStorageClass,
ForcePathStyle: defaultForcePath,
MaxRetries: defaultMaxRetries,
Expand Down
4 changes: 2 additions & 2 deletions internal/storages/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type Storage struct {
delimiter string
}

func NewStorage(ctx context.Context, cfg *Config, logLevel string) (*Storage, error) {
func NewStorage(ctx context.Context, cfg Config, logLevel string) (*Storage, error) {

ses, err := session.NewSession()
if err != nil {
Expand Down Expand Up @@ -167,7 +167,7 @@ func NewStorage(ctx context.Context, cfg *Config, logLevel string) (*Storage, er
return &Storage{
prefix: fixPrefix(path.Join(cfg.Bucket, cfg.Prefix)),
session: ses,
config: cfg,
config: &cfg,
service: service,
uploader: uploader,
}, nil
Expand Down