diff --git a/internal/cli/root.go b/internal/cli/root.go index 6bdca6f..3ed9c8c 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -7,7 +7,6 @@ import ( "code.lila.network/adoralaura/certwarden-deploy/internal/certificates" "code.lila.network/adoralaura/certwarden-deploy/internal/configuration" "code.lila.network/adoralaura/certwarden-deploy/internal/constants" - "code.lila.network/adoralaura/certwarden-deploy/internal/errlog" "code.lila.network/adoralaura/certwarden-deploy/internal/logger" "github.com/spf13/cobra" ) @@ -32,12 +31,14 @@ func handleRootCmd(cmd *cobra.Command, args []string) { os.Exit(1) } log := logger.InitializeLogger() - err = errlog.SetupSentry(log, config.Sentry.DSN) - if err != nil { - slog.Error("failed to initialize sentry", "error", err) - } + config.SubstituteKeys(log) - configuration.ValidateConfig(log, *config) + validation := config.IsValid() + if validation.HasMessages() { + validation.Print(log) + slog.Error("The configuration file has errors! Application cannot start unless all errors are corrected!") + panic(1) + } certificates.HandleCertificates(log, config) } diff --git a/internal/errlog/sentry.go b/internal/errlog/sentry.go deleted file mode 100644 index d380d3b..0000000 --- a/internal/errlog/sentry.go +++ /dev/null @@ -1,27 +0,0 @@ -package errlog - -import ( - "log/slog" - - "github.com/getsentry/sentry-go" -) - -func SetupSentry(logger *slog.Logger, dsn string) error { - if dsn == "" { - return nil - } - - err := sentry.Init(sentry.ClientOptions{ - Dsn: dsn, - // Set TracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production, - TracesSampleRate: 1.0, - }) - if err != nil { - logger.Error("failed to set up sentry") - } - // Flush buffered events before the program terminates. - - return nil -}