-
Notifications
You must be signed in to change notification settings - Fork 145
/
config.go
52 lines (41 loc) · 2.12 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package database
import (
"github.com/hatchet-dev/hatchet/internal/repository"
"github.com/spf13/viper"
)
type ConfigFile struct {
PostgresHost string `mapstructure:"host" json:"host,omitempty" default:"127.0.0.1"`
PostgresPort int `mapstructure:"port" json:"port,omitempty" default:"5433"`
PostgresUsername string `mapstructure:"username" json:"username,omitempty" default:"hatchet"`
PostgresPassword string `mapstructure:"password" json:"password,omitempty" default:"hatchet"`
PostgresDbName string `mapstructure:"dbName" json:"dbName,omitempty" default:"hatchet"`
PostgresSSLMode string `mapstructure:"sslMode" json:"sslMode,omitempty" default:"disable"`
Seed SeedConfigFile `mapstructure:"seed" json:"seed,omitempty"`
}
type SeedConfigFile struct {
AdminEmail string `mapstructure:"adminEmail" json:"adminEmail,omitempty" default:"admin@example.com"`
AdminPassword string `mapstructure:"adminPassword" json:"adminPassword,omitempty" default:"Admin123!!"`
AdminName string `mapstructure:"adminName" json:"adminName,omitempty" default:"Admin"`
DefaultTenantName string `mapstructure:"defaultTenantName" json:"defaultTenantName,omitempty" default:"default"`
DefaultTenantSlug string `mapstructure:"defaultTenantSlug" json:"defaultTenantSlug,omitempty" default:"default"`
IsDevelopment bool `mapstructure:"isDevelopment" json:"isDevelopment,omitempty" default:"false"`
}
type Config struct {
Disconnect func() error
Repository repository.Repository
Seed SeedConfigFile
}
func BindAllEnv(v *viper.Viper) {
v.BindEnv("host", "DATABASE_POSTGRES_HOST")
v.BindEnv("port", "DATABASE_POSTGRES_PORT")
v.BindEnv("username", "DATABASE_POSTGRES_USERNAME")
v.BindEnv("password", "DATABASE_POSTGRES_PASSWORD")
v.BindEnv("dbName", "DATABASE_POSTGRES_DB_NAME")
v.BindEnv("sslMode", "DATABASE_POSTGRES_SSL_MODE")
v.BindEnv("seed.adminEmail", "ADMIN_EMAIL")
v.BindEnv("seed.adminPassword", "ADMIN_PASSWORD")
v.BindEnv("seed.adminName", "ADMIN_NAME")
v.BindEnv("seed.defaultTenantName", "DEFAULT_TENANT_NAME")
v.BindEnv("seed.defaultTenantSlug", "DEFAULT_TENANT_SLUG")
v.BindEnv("seed.isDevelopment", "SEED_DEVELOPMENT")
}