chore: dummy store env
This commit is contained in:
parent
b513f517d8
commit
69333fd306
3 changed files with 16 additions and 4 deletions
|
@ -11,8 +11,8 @@ services:
|
|||
ports:
|
||||
- 8080
|
||||
environment:
|
||||
DUMMY_DATABASE: 1
|
||||
WEB_PUBLIC_REGISTRATION: 1
|
||||
USERSTORE_SQLITE_PATH: file:/tmp/miniauth.db
|
||||
|
||||
steps:
|
||||
- name: playwright
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
| Name | Description | Default |
|
||||
|------|-------------|---------|
|
||||
| DUMMY_DATABASE | Setup a new sqlite with the struct but no data for dev and test only | false |
|
||||
| USERSTORE_SQLITE_PATH | Path to the Sqlite Database | `none` |
|
||||
| PORT | Port for the Webserver | 8080 |
|
||||
| SMTP_SERVER | SMTP Server to send mails | `none` |
|
||||
|
|
17
main.go
17
main.go
|
@ -29,6 +29,7 @@ type gloableConfig struct {
|
|||
Port int `env:"PORT, default=8080"`
|
||||
SMTPConfig smtpclient.SMTPConfig `env:", prefix=SMTP_"`
|
||||
WebConfig web.WebConfig `env:", prefix=WEB_"`
|
||||
DummyDatabase bool `env:"DUMMY_DATABASE"`
|
||||
}
|
||||
|
||||
func config() gloableConfig {
|
||||
|
@ -53,9 +54,19 @@ func setupRouter(cfg gloableConfig) *gin.Engine {
|
|||
router.SetHTMLTemplate(loadTemplates())
|
||||
routesWeb := router.Group("/web")
|
||||
|
||||
us, err := userstore.NewStore(cfg.UserStoreConfig)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("cant init userstore")
|
||||
var us userstore.Store
|
||||
var err error
|
||||
if cfg.DummyDatabase {
|
||||
log.Warn().Msg("Use dummy store")
|
||||
us, err = userstore.NewDummyStore()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("cant init dummy store")
|
||||
}
|
||||
} else {
|
||||
us, err = userstore.NewStore(cfg.UserStoreConfig)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("cant init userstore")
|
||||
}
|
||||
}
|
||||
|
||||
sc := smtpclient.NewSMTPClient(cfg.SMTPConfig)
|
||||
|
|
Loading…
Add table
Reference in a new issue