-
Notifications
You must be signed in to change notification settings - Fork 0
/
env.go
56 lines (48 loc) · 1.08 KB
/
env.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
56
package cfg
import (
"log"
"os"
"path/filepath"
)
func getWd() string {
wd, err := os.Getwd()
if err != nil {
log.Fatalln("Couldn't find working directory", err)
}
return wd
}
func DataDir() string {
dataDir := os.Getenv("PONZU_DATA_DIR")
if dataDir == "" {
return getWd()
}
return dataDir
}
func TlsDir() string {
tlsDir := os.Getenv("PONZU_TLS_DIR")
if tlsDir == "" {
tlsDir = filepath.Join(getWd(), "cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "system", "tls")
}
return tlsDir
}
func AdminStaticDir() string {
staticDir := os.Getenv("PONZU_ADMINSTATIC_DIR")
if staticDir == "" {
staticDir = filepath.Join(getWd(), "cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "system", "admin", "static")
}
return staticDir
}
func UploadDir() string {
uploadDir := os.Getenv("PONZU_UPLOAD_DIR")
if uploadDir == "" {
uploadDir = filepath.Join(DataDir(),"uploads")
}
return uploadDir
}
func SearchDir() string {
searchDir := os.Getenv("PONZU_SEARCH_DIR")
if searchDir == "" {
searchDir = filepath.Join(DataDir(),"search")
}
return searchDir
}