Move ParseBool to optional (#33979)

(cherry picked from commit 25b6f388651c893ecafce918f27bef7e4ae9a967)
This commit is contained in:
Lunny Xiao 2025-03-23 20:53:30 -07:00 committed by Gusted
parent 9018e5bc19
commit f68d49cb9e
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 31 additions and 33 deletions

View file

@ -12,8 +12,8 @@ import (
"time"
"forgejo.org/modules/log"
"forgejo.org/modules/optional"
"forgejo.org/modules/user"
"forgejo.org/modules/util"
)
var ForgejoVersion = "1.0.0"
@ -162,7 +162,7 @@ func loadRunModeFrom(rootCfg ConfigProvider) {
// The following is a purposefully undocumented option. Please do not run Forgejo as root. It will only cause future headaches.
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
unsafeAllowRunAsRoot := ConfigSectionKeyBool(rootSec, "I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")
unsafeAllowRunAsRoot = unsafeAllowRunAsRoot || util.OptionalBoolParse(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value()
unsafeAllowRunAsRoot = unsafeAllowRunAsRoot || optional.ParseBool(os.Getenv("GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT")).Value()
RunMode = os.Getenv("GITEA_RUN_MODE")
if RunMode == "" {
RunMode = rootSec.Key("RUN_MODE").MustString("prod")