-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
47 lines (35 loc) · 913 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gitserver
import "path"
type Config struct {
Enable bool `toml:"enable"`
User string `toml:"user"`
CurrentUser bool `toml:"current_user"`
SSHUser string `toml:"ssh_user"`
GitShell string `toml:"git_shell"`
GitUserHome string `toml:"git_user_home"`
AuthorizedKeys string `toml:"authorized_keys"`
WatchKeys bool `toml:"watch_keys"`
MaxGitShellProcesses int `toml:"max_git_shell_processes"`
RefuseWhenBusy bool `toml:"refuse_when_busy"`
}
func (c *Config) FillDefault() error {
if c.User == "" {
c.User = "git"
}
if c.SSHUser == "" {
c.SSHUser = c.User
}
if c.GitShell == "" {
c.GitShell = "git-shell"
}
if c.GitUserHome == "" {
c.GitUserHome = "/home/git"
}
if c.AuthorizedKeys == "" {
c.AuthorizedKeys = path.Join(c.GitUserHome, ".ssh/authorized_keys")
}
if c.MaxGitShellProcesses < 0 {
c.MaxGitShellProcesses = 0
}
return nil
}