-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
55 lines (49 loc) · 1.19 KB
/
init.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
48
49
50
51
52
53
54
55
package config
import (
"github.com/revel/revel"
"os"
)
var gitBasePath string
var gitHttpBackEnd string
var ldapConn string
var ldapBaseDn string
func GitBasePath() string {
if gitBasePath == "" {
gitBasePath = os.Getenv("GIT_PROJECT_ROOT")
if gitBasePath == "" {
var found bool
gitBasePath, found = revel.Config.String("git.baseDir")
if !found {
panic("Cannot find git base path, please set git.baseDir in app.conf or system variable GIT_PROJECT_ROOT")
}
}
}
return gitBasePath
}
func GitHttpBackendPath() string {
if gitHttpBackEnd == "" {
gitHttpBackEnd = os.Getenv("GIT_HTTP_BACKEND")
if gitHttpBackEnd == "" {
return revel.Config.StringDefault("git.httpBackend", "/usr/lib/git-core/git-http-backend")
}
}
return gitHttpBackEnd
}
func LdapConnection() (string, bool) {
if ldapConn == "" {
ldapConn = os.Getenv("GIT_LDAP_CONNECTION")
if ldapConn == "" {
return revel.Config.String("ldap.connection")
}
}
return ldapConn, ldapConn != ""
}
func LdapBaseDn() (string, bool) {
if ldapBaseDn == "" {
ldapBaseDn = os.Getenv("GIT_LDAP_BASEDN")
if ldapBaseDn == "" {
return revel.Config.String("ldap.baseDn")
}
}
return ldapBaseDn, ldapBaseDn != ""
}