Skip to content

Commit

Permalink
feat(datastore): add mock storage option (#289)
Browse files Browse the repository at this point in the history
* feat(datastore): add mock storage option

* fix(config): remove unused config
  • Loading branch information
LucasMrqes authored Jun 4, 2024
1 parent 20c1f86 commit c177cf0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions deploy/charts/burrito/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ config:
datastore:
serviceAccounts: []
storage:
mock: false # -- Use in-memory storage for testing - not intended for production use
gcs: {}
azure: {}
aws: {}
Expand Down
1 change: 1 addition & 0 deletions internal/burrito/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type StorageConfig struct {
GCS GCSConfig `mapstructure:"gcs"`
S3 S3Config `mapstructure:"s3"`
Azure AzureConfig `mapstructure:"azure"`
Mock bool `mapstructure:"mock"`
}

type GCSConfig struct {
Expand Down
6 changes: 6 additions & 0 deletions internal/datastore/storage/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"fmt"
"strconv"

log "github.com/sirupsen/logrus"

"github.com/padok-team/burrito/internal/burrito/config"
"github.com/padok-team/burrito/internal/datastore/storage/azure"
errors "github.com/padok-team/burrito/internal/datastore/storage/error"
"github.com/padok-team/burrito/internal/datastore/storage/gcs"
"github.com/padok-team/burrito/internal/datastore/storage/mock"
"github.com/padok-team/burrito/internal/datastore/storage/s3"
)

Expand Down Expand Up @@ -68,6 +71,9 @@ func New(config config.Config) Storage {
return Storage{Backend: gcs.New(config.Datastore.Storage.GCS)}
case config.Datastore.Storage.S3.Bucket != "":
return Storage{Backend: s3.New(config.Datastore.Storage.S3)}
case config.Datastore.Storage.Mock:
log.Warn("Using mock storage backend - for testing only - no data will only be stored in memory and will be lost when the process exits")
return Storage{Backend: mock.New()}
}
return Storage{}
}
Expand Down

0 comments on commit c177cf0

Please sign in to comment.