Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix settings not being loaded at CLI (#26402) #33048

Merged
merged 2 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/admin_user_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ var microcmdUserCreate = &cli.Command{
}

func runCreateUser(c *cli.Context) error {
// this command highly depends on the many setting options (create org, visibility, etc.), so it must have a full setting load first
// duplicate setting loading should be safe at the moment, but it should be refactored & improved in the future.
setting.LoadSettings()

if err := argsSet(c, "email"); err != nil {
return err
}
Expand Down
11 changes: 11 additions & 0 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"

_ "net/http/pprof" // Used for debugging if enabled and a web server is running

Expand Down Expand Up @@ -115,6 +116,16 @@ func showWebStartupMessage(msg string) {
log.Info("* CustomPath: %s", setting.CustomPath)
log.Info("* ConfigFile: %s", setting.CustomConf)
log.Info("%s", msg) // show startup message

if setting.CORSConfig.Enabled {
log.Info("CORS Service Enabled")
}
if setting.DefaultUILocation != time.Local {
log.Info("Default UI Location is %v", setting.DefaultUILocation.String())
}
if setting.MailService != nil {
log.Info("Mail Service Enabled: RegisterEmailConfirm=%v, Service.EnableNotifyMail=%v", setting.Service.RegisterEmailConfirm, setting.Service.EnableNotifyMail)
}
}

func serveInstall(ctx *cli.Context) error {
Expand Down
5 changes: 0 additions & 5 deletions modules/setting/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package setting

import (
"time"

"code.gitea.io/gitea/modules/log"
)

// CORSConfig defines CORS settings
Expand All @@ -28,7 +26,4 @@ var CORSConfig = struct {

func loadCorsFrom(rootCfg ConfigProvider) {
mustMapSetting(rootCfg, "cors", &CORSConfig)
if CORSConfig.Enabled {
log.Info("CORS Service Enabled")
}
}
2 changes: 1 addition & 1 deletion modules/setting/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func IndexerGlobFromString(globstr string) []*GlobMatcher {
expr = strings.TrimSpace(expr)
if expr != "" {
if g, err := GlobMatcherCompile(expr, '.', '/'); err != nil {
log.Info("Invalid glob expression '%s' (skipped): %v", expr, err)
log.Warn("Invalid glob expression '%s' (skipped): %v", expr, err)
} else {
extarr = append(extarr, g)
}
Expand Down
4 changes: 0 additions & 4 deletions modules/setting/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ func loadMailerFrom(rootCfg ConfigProvider) {
MailService.OverrideEnvelopeFrom = true
MailService.EnvelopeFrom = parsed.Address
}

log.Info("Mail Service Enabled")
}

func loadRegisterMailFrom(rootCfg ConfigProvider) {
Expand All @@ -267,7 +265,6 @@ func loadRegisterMailFrom(rootCfg ConfigProvider) {
return
}
Service.RegisterEmailConfirm = true
log.Info("Register Mail Service Enabled")
}

func loadNotifyMailFrom(rootCfg ConfigProvider) {
Expand All @@ -278,7 +275,6 @@ func loadNotifyMailFrom(rootCfg ConfigProvider) {
return
}
Service.EnableNotifyMail = true
log.Info("Notify Mail Service Enabled")
}

func tryResolveAddr(addr string) []net.IPAddr {
Expand Down
2 changes: 0 additions & 2 deletions modules/setting/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,4 @@ func loadSessionFrom(rootCfg ConfigProvider) {
SessionConfig.ProviderConfig = string(shadowConfig)
SessionConfig.OriginalProvider = SessionConfig.Provider
SessionConfig.Provider = "VirtualSession"

log.Info("Session Service Enabled")
}
1 change: 0 additions & 1 deletion modules/setting/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func loadTimeFrom(rootCfg ConfigProvider) {
if err != nil {
log.Fatal("Load time zone failed: %v", err)
}
log.Info("Default UI Location is %v", zone)
}
if DefaultUILocation == nil {
DefaultUILocation = time.Local
Expand Down
Loading