outpost: fix crash when common keys are not defined in config
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
923fbac5b0
commit
198e5ce642
|
@ -4,7 +4,6 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
httptransport "github.com/go-openapi/runtime/client"
|
||||
|
@ -35,23 +34,31 @@ func doGlobalSetup(config map[string]interface{}) {
|
|||
}
|
||||
log.WithField("buildHash", constants.BUILD()).WithField("version", constants.VERSION).Info("Starting authentik outpost")
|
||||
|
||||
env := config[ConfigErrorReportingEnvironment].(string)
|
||||
var dsn string
|
||||
if config[ConfigErrorReportingEnabled].(bool) {
|
||||
dsn = "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8"
|
||||
log.WithField("env", env).Debug("Error reporting enabled")
|
||||
sentryEnv := "customer-outpost"
|
||||
sentryEnable := true
|
||||
if cSentryEnv, ok := config[ConfigErrorReportingEnvironment]; ok {
|
||||
if ccSentryEnv, ok := cSentryEnv.(string); ok {
|
||||
sentryEnv = ccSentryEnv
|
||||
}
|
||||
|
||||
}
|
||||
var dsn string
|
||||
if cSentryEnable, ok := config[ConfigErrorReportingEnabled]; ok {
|
||||
if ccSentryEnable, ok := cSentryEnable.(bool); ok {
|
||||
sentryEnable = ccSentryEnable
|
||||
}
|
||||
}
|
||||
if sentryEnable {
|
||||
dsn = "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8"
|
||||
log.WithField("env", sentryEnv).Debug("Error reporting enabled")
|
||||
err := sentry.Init(sentry.ClientOptions{
|
||||
Dsn: dsn,
|
||||
Environment: env,
|
||||
Environment: sentryEnv,
|
||||
TracesSampleRate: 1,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("sentry.Init: %s", err)
|
||||
}
|
||||
|
||||
defer sentry.Flush(2 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
// GetTLSTransport Get a TLS transport instance, that skips verification if configured via environment variables.
|
||||
|
|
Reference in New Issue