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

Make CustomPath, CustomConf and AppWorkPath configurable at build #6631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
53fc42e
Make CustomPath, CustomConf and AppWorkPath configurable at build
zeripath Apr 15, 2019
b9359aa
Allow LDFLAGS to be passed in to Makefile
zeripath Apr 15, 2019
601efd0
Attempt to make the docker use the CustomPath functionality
zeripath Apr 15, 2019
2c75e8d
Try a slightly different thing to force docker binary
zeripath Apr 15, 2019
5ea69a9
Argh I hate Makefiles
zeripath Apr 15, 2019
397d62f
Ignore the new gitea-docker binary
zeripath Apr 15, 2019
638ed17
Adjust CustomConf setting to make them more friendly
zeripath Apr 15, 2019
18264fc
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 15, 2019
2c9ba87
Add comment on SetCustomPath
zeripath Apr 15, 2019
2401225
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 15, 2019
28f9283
Add documentation
zeripath Apr 15, 2019
87b46c9
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 16, 2019
c1845d4
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 16, 2019
c0fcd4b
make -c and -C work globally and update the documentation
zeripath Apr 16, 2019
eafba00
formatting in command-line.en-us.md
zeripath Apr 16, 2019
782a288
remove extraneous LDFLAGS
zeripath Apr 16, 2019
d6e697d
Remove extraneous EXECUTABLE setting
zeripath Apr 16, 2019
dca2763
Remove change to docker/Makefile
sapk Apr 16, 2019
e4ce70b
Remove docker build changes
zeripath Apr 16, 2019
e17bb4f
Missed one
zeripath Apr 16, 2019
a4f481d
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 17, 2019
a0182d3
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 19, 2019
7e66235
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
zeripath Apr 23, 2019
2fff29e
Merge branch 'master' into Make-CustomPath-Configurable-At-Build
techknowlogick Apr 29, 2019
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
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ SHASUM ?= shasum -a 256
export PATH := $($(GO) env GOPATH)/bin:$(PATH)

ifeq ($(OS), Windows_NT)
EXECUTABLE := gitea.exe
EXECUTABLE ?= gitea.exe
else
EXECUTABLE := gitea
EXECUTABLE ?= gitea
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
Expand Down Expand Up @@ -39,7 +39,7 @@ else
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
endif

LDFLAGS := -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"

PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell $(GO) list ./... | grep -v /vendor/)))
SOURCES ?= $(shell find . -name "*.go" -type f)
Expand Down Expand Up @@ -70,12 +70,6 @@ TEST_MSSQL_DBNAME ?= gitea
TEST_MSSQL_USERNAME ?= sa
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1

ifeq ($(OS), Windows_NT)
EXECUTABLE := gitea.exe
else
EXECUTABLE := gitea
endif

# $(call strip-suffix,filename)
strip-suffix = $(firstword $(subst ., ,$(1)))

Expand Down
76 changes: 0 additions & 76 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ var (
Name: "admin",
Usage: "User is an admin",
},
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
cli.BoolFlag{
Name: "random-password",
Usage: "Generate a random password for the user",
Expand Down Expand Up @@ -96,11 +91,6 @@ var (
Value: "",
Usage: "New password to set for user",
},
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

Expand All @@ -123,26 +113,12 @@ var (
Name: "hooks",
Usage: "Regenerate git-hooks",
Action: runRegenerateHooks,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

microcmdRegenKeys = cli.Command{
Name: "keys",
Usage: "Regenerate authorized_keys file",
Action: runRegenerateKeys,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

subcmdAuth = cli.Command{
Expand All @@ -160,13 +136,6 @@ var (
Name: "list",
Usage: "List auth sources",
Action: runListAuth,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

idFlag = cli.Int64Flag{
Expand All @@ -178,22 +147,9 @@ var (
Name: "delete",
Usage: "Delete specific auth source",
Action: runDeleteAuth,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
idFlag,
},
}

oauthCLIFlags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
cli.StringFlag{
Name: "name",
Value: "",
Expand Down Expand Up @@ -266,10 +222,6 @@ func runChangePassword(c *cli.Context) error {
return err
}

if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand Down Expand Up @@ -331,10 +283,6 @@ func runCreateUser(c *cli.Context) error {
return errors.New("must set either password or random-password flag")
}

if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand Down Expand Up @@ -430,21 +378,13 @@ func getReleaseCount(id int64) (int64, error) {
}

func runRegenerateHooks(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
return models.SyncRepositoryHooks()
}

func runRegenerateKeys(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand Down Expand Up @@ -473,10 +413,6 @@ func parseOAuth2Config(c *cli.Context) *models.OAuth2Config {
}

func runAddOauth(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand All @@ -490,10 +426,6 @@ func runAddOauth(c *cli.Context) error {
}

func runUpdateOauth(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if !c.IsSet("id") {
return fmt.Errorf("--id flag is missing")
}
Expand Down Expand Up @@ -561,10 +493,6 @@ func runUpdateOauth(c *cli.Context) error {
}

func runListAuth(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand All @@ -587,10 +515,6 @@ func runListAuth(c *cli.Context) error {
}

func runDeleteAuth(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if !c.IsSet("id") {
return fmt.Errorf("--id flag is missing")
}
Expand Down
8 changes: 0 additions & 8 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ var CmdDump = cli.Command{
It can be used for backup and capture Gitea server image to send to maintainer`,
Action: runDump,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
cli.StringFlag{
Name: "file, f",
Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()),
Expand All @@ -61,9 +56,6 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
}

func runDump(ctx *cli.Context) error {
if ctx.IsSet("config") {
setting.CustomConf = ctx.String("config")
}
setting.NewContext()
setting.NewServices() // cannot access session settings otherwise
models.LoadConfigs()
Expand Down
26 changes: 0 additions & 26 deletions cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"

"github.com/urfave/cli"
Expand All @@ -28,13 +27,6 @@ var (
Name: "hook",
Usage: "Delegate commands to corresponding Git hooks",
Description: "This should only be called by Git",
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
Subcommands: []cli.Command{
subcmdHookPreReceive,
subcmdHookUpdate,
Expand Down Expand Up @@ -67,12 +59,6 @@ func runHookPreReceive(c *cli.Context) error {
return nil
}

if c.IsSet("config") {
setting.CustomConf = c.String("config")
} else if c.GlobalIsSet("config") {
setting.CustomConf = c.GlobalString("config")
}

setup("hooks/pre-receive.log")

// the environment setted on serv command
Expand Down Expand Up @@ -143,12 +129,6 @@ func runHookUpdate(c *cli.Context) error {
return nil
}

if c.IsSet("config") {
setting.CustomConf = c.String("config")
} else if c.GlobalIsSet("config") {
setting.CustomConf = c.GlobalString("config")
}

setup("hooks/update.log")

return nil
Expand All @@ -159,12 +139,6 @@ func runHookPostReceive(c *cli.Context) error {
return nil
}

if c.IsSet("config") {
setting.CustomConf = c.String("config")
} else if c.GlobalIsSet("config") {
setting.CustomConf = c.GlobalString("config")
}

setup("hooks/post-receive.log")

// the environment setted on serv command
Expand Down
10 changes: 0 additions & 10 deletions cmd/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/setting"

"github.com/urfave/cli"
)
Expand Down Expand Up @@ -41,19 +40,10 @@ var CmdKeys = cli.Command{
Value: "",
Usage: "Base64 encoded content of the SSH key provided to the SSH Server (requires type to be provided too)",
},
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

func runKeys(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}

if !c.IsSet("username") {
return errors.New("No username provided")
}
Expand Down
11 changes: 0 additions & 11 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,9 @@ var CmdMigrate = cli.Command{
Usage: "Migrate the database",
Description: "This is a command for migrating the database, so that you can run gitea admin create-user before starting the server.",
Action: runMigrate,
Flags: []cli.Flag{
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
},
}

func runMigrate(ctx *cli.Context) error {
if ctx.IsSet("config") {
setting.CustomConf = ctx.String("config")
}

if err := initDB(); err != nil {
return err
}
Expand Down
8 changes: 0 additions & 8 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ var CmdServ = cli.Command{
Description: `Serv provide access auth for repositories`,
Action: runServ,
Flags: []cli.Flag{
cli.StringFlag{
techknowlogick marked this conversation as resolved.
Show resolved Hide resolved
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
cli.BoolFlag{
Name: "enable-pprof",
},
Expand Down Expand Up @@ -109,9 +104,6 @@ func fail(userMessage, logMessage string, args ...interface{}) {
}

func runServ(c *cli.Context) error {
if c.IsSet("config") {
setting.CustomConf = c.String("config")
}
setup("serv.log")

if setting.SSH.Disabled {
Expand Down
9 changes: 0 additions & 9 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ and it takes care of all the other things for you`,
Value: "3000",
Usage: "Temporary port number to prevent conflict",
},
cli.StringFlag{
Name: "config, c",
Value: "custom/conf/app.ini",
Usage: "Custom configuration file path",
},
cli.StringFlag{
zeripath marked this conversation as resolved.
Show resolved Hide resolved
Name: "pid, P",
Value: "/var/run/gitea.pid",
Expand Down Expand Up @@ -110,10 +105,6 @@ func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
}

func runWeb(ctx *cli.Context) error {
if ctx.IsSet("config") {
setting.CustomConf = ctx.String("config")
}

if ctx.IsSet("pid") {
setting.CustomPID = ctx.String("pid")
}
Expand Down
1 change: 1 addition & 0 deletions contrib/pr/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func runPR() {
if err != nil {
log.Fatal(err)
}
setting.SetCustomPathAndConf("", "")
setting.NewContext()

setting.RepoRootPath, err = ioutil.TempDir(os.TempDir(), "repos")
Expand Down
Loading