Cleanup environment naming.

This commit is contained in:
mikestefanello 2021-12-14 20:17:09 -05:00
parent 0a8d08d8bd
commit b7f5704b2b
2 changed files with 11 additions and 11 deletions

View file

@ -14,15 +14,15 @@ const (
StaticPrefix = "files" StaticPrefix = "files"
) )
type Env string type Environment string
const ( const (
EnvLocal Env = "local" EnvLocal Environment = "local"
EnvTest Env = "test" EnvTest Environment = "test"
EnvDevelop Env = "dev" EnvDevelop Environment = "dev"
EnvStaging Env = "staging" EnvStaging Environment = "staging"
EnvQA Env = "qa" EnvQA Environment = "qa"
EnvProduction Env = "prod" EnvProduction Environment = "prod"
) )
type ( type (
@ -47,7 +47,7 @@ type (
// AppConfig stores application configuration // AppConfig stores application configuration
AppConfig struct { AppConfig struct {
Name string `env:"APP_NAME,default=Goweb"` Name string `env:"APP_NAME,default=Goweb"`
Environment Env `env:"APP_ENV,default=local"` Environment Environment `env:"APP_ENVIRONMENT,default=local"`
EncryptionKey string `env:"APP_ENCRYPTION_KEY,default=?E(G+KbPeShVmYq3t6w9z$C&F)J@McQf"` EncryptionKey string `env:"APP_ENCRYPTION_KEY,default=?E(G+KbPeShVmYq3t6w9z$C&F)J@McQf"`
Timeout time.Duration `env:"APP_TIMEOUT,default=20s"` Timeout time.Duration `env:"APP_TIMEOUT,default=20s"`
} }
@ -87,8 +87,8 @@ func GetConfig() (Config, error) {
return cfg, err return cfg, err
} }
func SwitchEnv(env Env) { func SwitchEnvironment(env Environment) {
if err := os.Setenv("APP_ENV", string(env)); err != nil { if err := os.Setenv("APP_ENVIRONMENT", string(env)); err != nil {
panic(err) panic(err)
} }
} }

View file

@ -23,7 +23,7 @@ var (
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// Set the environment to test // Set the environment to test
config.SwitchEnv(config.EnvTest) config.SwitchEnvironment(config.EnvTest)
// Start a test HTTP server // Start a test HTTP server
c = container.NewContainer() c = container.NewContainer()