mirror of
https://github.com/yanislav-igonin/micrach
synced 2024-12-22 22:32:33 +03:00
feat: hide seeds under env var
This commit is contained in:
parent
d456be5e9a
commit
ac006d5f1b
@ -1,3 +1,4 @@
|
|||||||
ENV=debug
|
ENV=debug
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
SEED_DB=true
|
||||||
POSTGRES_URL=postgres://localhost/micrach
|
POSTGRES_URL=postgres://localhost/micrach
|
@ -9,6 +9,7 @@ import (
|
|||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Env string
|
Env string
|
||||||
Port int
|
Port int
|
||||||
|
SeedDb bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbConfig struct {
|
type DbConfig struct {
|
||||||
@ -30,9 +31,13 @@ func getAppConfig() AppConfig {
|
|||||||
panic(fmt.Sprintf("Could not parse %s to int", portString))
|
panic(fmt.Sprintf("Could not parse %s to int", portString))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seedDbString := os.Getenv("SEED_DB")
|
||||||
|
seedDb := seedDbString == "true"
|
||||||
|
|
||||||
return AppConfig{
|
return AppConfig{
|
||||||
Env: env,
|
Env: env,
|
||||||
Port: port,
|
Port: port,
|
||||||
|
SeedDb: seedDb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
main.go
2
main.go
@ -19,7 +19,9 @@ func main() {
|
|||||||
Db.Init()
|
Db.Init()
|
||||||
defer Db.Pool.Close()
|
defer Db.Pool.Close()
|
||||||
gin.SetMode(Config.App.Env)
|
gin.SetMode(Config.App.Env)
|
||||||
|
if Config.App.SeedDb {
|
||||||
Repositories.Seed()
|
Repositories.Seed()
|
||||||
|
}
|
||||||
|
|
||||||
err := Utils.CreateUploadsFolder()
|
err := Utils.CreateUploadsFolder()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user