Skip to content

Commit

Permalink
add storage type configuration using environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-zanutto authored Mar 28, 2024
1 parent 990e8d5 commit a6cd803
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions internal/storages/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package builder
import (
"context"
"errors"
"os"

"github.com/greenmaskio/greenmask/internal/domains"
"github.com/greenmaskio/greenmask/internal/storages"
Expand All @@ -27,9 +28,10 @@ import (
func GetStorage(ctx context.Context, stCfg *domains.StorageConfig, logCgf *domains.LogConfig) (
storages.Storager, error,
) {
if stCfg.Directory != nil {
envCfg := os.Getenv("STORAGE_TYPE")
if stCfg.Directory != nil || envCfg == "directory" {
return directory.NewStorage(stCfg.Directory)
} else if stCfg.S3 != nil {
} else if (stCfg.S3 != nil || envCfg == "s3" {

Check failure on line 34 in internal/storages/builder/builder.go

View workflow job for this annotation

GitHub Actions / unit-tests

syntax error: unexpected {, expected )
return s3.NewStorage(ctx, stCfg.S3, logCgf.Level)

Check failure on line 35 in internal/storages/builder/builder.go

View workflow job for this annotation

GitHub Actions / unit-tests

syntax error: unexpected return, expected {
}

Check failure on line 36 in internal/storages/builder/builder.go

View workflow job for this annotation

GitHub Actions / unit-tests

syntax error: unexpected }, expected expression
return nil, errors.New("no one storage was provided")
Expand Down

0 comments on commit a6cd803

Please sign in to comment.