From 4853451db18b1de42dd8be104b7e426b888caa0d Mon Sep 17 00:00:00 2001 From: Joao Zanutto Date: Thu, 4 Apr 2024 19:29:29 -0700 Subject: [PATCH 1/2] remove pointer from storage config definition --- internal/domains/config.go | 4 ++-- internal/storages/directory/config.go | 4 ++-- internal/storages/directory/directory.go | 2 +- internal/storages/s3/config.go | 4 ++-- internal/storages/s3/s3.go | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/domains/config.go b/internal/domains/config.go index cb688ce9..009029a6 100644 --- a/internal/domains/config.go +++ b/internal/domains/config.go @@ -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 { diff --git a/internal/storages/directory/config.go b/internal/storages/directory/config.go index a283f0ab..97bc18f1 100644 --- a/internal/storages/directory/config.go +++ b/internal/storages/directory/config.go @@ -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 { diff --git a/internal/storages/directory/directory.go b/internal/storages/directory/directory.go index 9e263b67..8e72d0b8 100644 --- a/internal/storages/directory/directory.go +++ b/internal/storages/directory/directory.go @@ -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 { diff --git a/internal/storages/s3/config.go b/internal/storages/s3/config.go index 0c5ad765..53b97681 100644 --- a/internal/storages/s3/config.go +++ b/internal/storages/s3/config.go @@ -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, diff --git a/internal/storages/s3/s3.go b/internal/storages/s3/s3.go index 350f5a8e..790b59da 100644 --- a/internal/storages/s3/s3.go +++ b/internal/storages/s3/s3.go @@ -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 { @@ -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 From a2d448d9089496982ac075af2d3e5cb7fed76ce5 Mon Sep 17 00:00:00 2001 From: Joao Zanutto Date: Thu, 4 Apr 2024 19:33:09 -0700 Subject: [PATCH 2/2] fix broken test --- internal/storages/directory/directiry_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/storages/directory/directiry_test.go b/internal/storages/directory/directiry_test.go index dc5386b5..a554c583 100644 --- a/internal/storages/directory/directiry_test.go +++ b/internal/storages/directory/directiry_test.go @@ -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) }