Skip to content

Commit baed0da

Browse files
authored
- Removed Environment from ServerConfiguration struct to the (#167)
Configuration struct. - Added CONVOY_DISABLE_ENDPOINT env var.
1 parent c486c76 commit baed0da

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func main() {
7575
err = sentry.Init(sentry.ClientOptions{
7676
Debug: true,
7777
Dsn: cfg.Sentry.Dsn,
78-
Environment: cfg.Server.Environment,
78+
Environment: cfg.Environment,
7979
})
8080
if err != nil {
8181
return err

config/config.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ type SentryConfiguration struct {
2424
}
2525

2626
type ServerConfiguration struct {
27-
Environment string `json:"environment"`
28-
HTTP struct {
27+
HTTP struct {
2928
Port uint32 `json:"port"`
3029
} `json:"http"`
3130
}
@@ -88,6 +87,7 @@ type Configuration struct {
8887
Strategy StrategyConfiguration `json:"strategy"`
8988
Signature SignatureConfiguration `json:"signature"`
9089
SMTP SMTPConfiguration `json:"smtp"`
90+
Environment string `json:"env"`
9191
DisableEndpoint bool `json:"disable_endpoint"`
9292
}
9393

@@ -96,6 +96,10 @@ type QueueProvider string
9696
type StrategyProvider string
9797
type SignatureHeaderProvider string
9898

99+
const (
100+
DevelopmentEnvironment string = "development"
101+
)
102+
99103
const (
100104
NoAuthProvider AuthProvider = "none"
101105
BasicAuthProvider AuthProvider = "basic"
@@ -145,13 +149,13 @@ func LoadConfig(p string) error {
145149
}
146150
}
147151

148-
if serverEnv := os.Getenv("CONVOY_SERVER_ENV"); serverEnv != "" {
149-
c.Server.Environment = serverEnv
152+
if env := os.Getenv("CONVOY_ENV"); env != "" {
153+
c.Environment = env
150154
}
151155

152156
// if it's still empty, set it to development
153-
if c.Server.Environment == "" {
154-
c.Server.Environment = "development"
157+
if c.Environment == "" {
158+
c.Environment = DevelopmentEnvironment
155159
}
156160

157161
if sentryDsn := os.Getenv("CONVOY_SENTRY_DSN"); sentryDsn != "" {
@@ -240,6 +244,12 @@ func LoadConfig(p string) error {
240244

241245
}
242246

247+
if e := os.Getenv("CONVOY_DISABLE_ENDPOINT"); e != "" {
248+
if d, err := strconv.ParseBool(e); err != nil {
249+
c.DisableEndpoint = d
250+
}
251+
}
252+
243253
c.UIAuthorizedUsers = parseAuthorizedUsers(c.UIAuth)
244254

245255
cfgSingleton.Store(c)

convoy-docker.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"environment": "dev",
2+
"environment": "development",
33
"database": {
4-
"dsn": "mongodb://root:rootpassword@mongodb:27017/newConvoy?authSource=admin"
4+
"dsn": "mongodb://root:rootpassword@mongodb:27017/convoy?authSource=admin"
55
},
66
"queue": {
77
"type": "redis",

0 commit comments

Comments
 (0)