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:
|
ports:
|
||||||
- 8080
|
- 8080
|
||||||
environment:
|
environment:
|
||||||
|
DUMMY_DATABASE: 1
|
||||||
WEB_PUBLIC_REGISTRATION: 1
|
WEB_PUBLIC_REGISTRATION: 1
|
||||||
USERSTORE_SQLITE_PATH: file:/tmp/miniauth.db
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: playwright
|
- name: playwright
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
| Name | Description | Default |
|
| 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` |
|
| USERSTORE_SQLITE_PATH | Path to the Sqlite Database | `none` |
|
||||||
| PORT | Port for the Webserver | 8080 |
|
| PORT | Port for the Webserver | 8080 |
|
||||||
| SMTP_SERVER | SMTP Server to send mails | `none` |
|
| 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"`
|
Port int `env:"PORT, default=8080"`
|
||||||
SMTPConfig smtpclient.SMTPConfig `env:", prefix=SMTP_"`
|
SMTPConfig smtpclient.SMTPConfig `env:", prefix=SMTP_"`
|
||||||
WebConfig web.WebConfig `env:", prefix=WEB_"`
|
WebConfig web.WebConfig `env:", prefix=WEB_"`
|
||||||
|
DummyDatabase bool `env:"DUMMY_DATABASE"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func config() gloableConfig {
|
func config() gloableConfig {
|
||||||
|
@ -53,9 +54,19 @@ func setupRouter(cfg gloableConfig) *gin.Engine {
|
||||||
router.SetHTMLTemplate(loadTemplates())
|
router.SetHTMLTemplate(loadTemplates())
|
||||||
routesWeb := router.Group("/web")
|
routesWeb := router.Group("/web")
|
||||||
|
|
||||||
us, err := userstore.NewStore(cfg.UserStoreConfig)
|
var us userstore.Store
|
||||||
if err != nil {
|
var err error
|
||||||
log.Fatal().Err(err).Msg("cant init userstore")
|
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)
|
sc := smtpclient.NewSMTPClient(cfg.SMTPConfig)
|
||||||
|
|
Loading…
Add table
Reference in a new issue